Problem with threads

Discussion in 'Python' started by Stephan Popp, Jul 18, 2005.

  1. Stephan Popp

    Stephan Popp Guest

    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
     
    Stephan Popp, Jul 18, 2005
    #1
    1. Advertising

  2. 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.
     
    Simon Dahlbacka, Jul 18, 2005
    #2
    1. Advertising

  3. Stephan Popp

    Peter Hansen Guest

    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
     
    Peter Hansen, Jul 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yoda
    Replies:
    2
    Views:
    430
    =?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=
    Aug 1, 2005
  2. threads without threads

    , Aug 27, 2004, in forum: C Programming
    Replies:
    4
    Views:
    396
    William Ahern
    Aug 27, 2004
  3. Pedro Pinto

    Java Threads - Get running threads

    Pedro Pinto, Apr 8, 2008, in forum: Java
    Replies:
    2
    Views:
    1,436
    Arne Vajhøj
    Apr 9, 2008
  4. Une bévue
    Replies:
    0
    Views:
    141
    Une bévue
    Jun 14, 2006
  5. prameela

    Is it a gtk2 problem or Threads problem

    prameela, Mar 19, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    80
    prameela
    Mar 19, 2006
Loading...

Share This Page