By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,144 Members | 972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,144 IT Pros & Developers. It's quick & easy.

Problem with threads

P: n/a
Hi all,
I've got a problem with stopping python-threads.
I'm starting a thread with twisteds reactor.deferToThread which start a
methodcall in a seperate thread. In this thread a swig-wrapped c++ module is
running.
Now I want to stop the running thread from the main thread or another one, and
have no idea how to do it.
I hope it has become clear what I want to do, if not feel free to ask.
I'm running python 2.4

Thanks in advance,
Stephan
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You cannot really do that*. Use a flag or something that the thread
checks if it should shut down.

/Simon

* well actually you can, sort of by using
int PyThreadState_SetAsyncExc( long id, PyObject *exc) from C API.
However, if you do that you swap one problem for a sh*tload of others,
because of the *async* part.

Jul 21 '05 #2

P: n/a
Stephan Popp wrote:
I've got a problem with stopping python-threads.
I'm starting a thread with twisteds reactor.deferToThread which start a
methodcall in a seperate thread. In this thread a swig-wrapped c++ module is
running.
Now I want to stop the running thread from the main thread or another one, and
have no idea how to do it.


If this external call into the C++ module is "long running", and doesn't
itself provide a way to terminate before it's done, you can't do what
you want unless you use a separate process entirely.

-Peter
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.