Re: QThread.terminate in Python 3

Discussion in 'Python' started by Dennis Lee Bieber, Sep 23, 2012.

  1. On Sun, 23 Sep 2012 20:39:11 +0430, Lee Harr <>
    declaimed the following in gmane.comp.python.general:

    > I understand that use of QThread.terminate is discouraged,
    > but it has worked well previously and I would like to continue
    > this use if possible.
    >

    And now you've encountered the reason it is discouraged.

    Pretty much ALL the threading libraries I've encountered discourage
    arbitrary "killing" of threads. The recommended method is a cooperative
    system by which the threads detect, somehow, a signal (special token on
    an input queue, global boolean, thread-local boolean that can be set
    external to the thread, etc.) and then clean up and exit "normally".

    Likely the presense of time.sleep() in the thread is providing: 1) a
    task switch to the main thread (or whichever) is invoking the
    termination and, 2) a clean thread state where termination doesn't risk
    any dangling operations [the thread is blocked waiting for a signal to
    continue] vs having a task switch occur in the middle of a sequence of
    Python op-codes and then being terminated with an unfinished
    statement...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Sep 23, 2012
    #1
    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. Pradnyesh Sawant

    problem with qthread and signal/slot

    Pradnyesh Sawant, Apr 14, 2007, in forum: Python
    Replies:
    0
    Views:
    472
    Pradnyesh Sawant
    Apr 14, 2007
  2. daved170

    PyQT Qthread stuck main app

    daved170, Sep 15, 2009, in forum: Python
    Replies:
    0
    Views:
    432
    daved170
    Sep 15, 2009
  3. Lee Harr

    QThread.terminate in Python 3

    Lee Harr, Sep 23, 2012, in forum: Python
    Replies:
    0
    Views:
    209
    Lee Harr
    Sep 23, 2012
  4. Lee Harr

    Re: QThread.terminate in Python 3

    Lee Harr, Sep 29, 2012, in forum: Python
    Replies:
    0
    Views:
    200
    Lee Harr
    Sep 29, 2012
  5. Dennis Lee Bieber

    Re: QThread.terminate in Python 3

    Dennis Lee Bieber, Sep 29, 2012, in forum: Python
    Replies:
    0
    Views:
    259
    Dennis Lee Bieber
    Sep 29, 2012
Loading...

Share This Page