Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: QThread.terminate in Python 3

Reply
Thread Tools

Re: QThread.terminate in Python 3

 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      09-23-2012
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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. Löwis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57