Problem with threads

S

Stephan Popp

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
 
S

Simon Dahlbacka

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.
 
P

Peter Hansen

Stephan said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top