Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29836 > unrolled thread

Re: QThread.terminate in Python 3

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2012-09-23 13:58 -0400
Last post2012-09-23 13:58 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: QThread.terminate in Python 3 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-23 13:58 -0400

#29836 — Re: QThread.terminate in Python 3

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-09-23 13:58 -0400
SubjectRe: QThread.terminate in Python 3
Message-ID<mailman.1136.1348423115.27098.python-list@python.org>
On Sun, 23 Sep 2012 20:39:11 +0430, Lee Harr <missive@hotmail.com>
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
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web