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


Groups > comp.lang.python > #30455

Re: QThread.terminate in Python 3

Path csiph.com!usenet.pasdenom.info!news.albasani.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <missive@hotmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'exception': 0.03; 'subject:Python': 0.05; 'ok.': 0.07; 'python': 0.09; 'url:googlecode': 0.09; 'thread': 0.11; 'elsewhere.': 0.16; 'least,': 0.16; 'thread.': 0.16; 'previously': 0.18; 'saying': 0.18; 'causing': 0.20; 'to:name:python-list@python.org': 0.20; 'ctypes': 0.22; 'raise': 0.24; 'actual': 0.28; 'trouble': 0.28; 'run': 0.28; 'facing': 0.29; 'case,': 0.29; 'worked': 0.30; 'code': 0.31; 'point': 0.31; 'problem': 0.33; 'to:addr:python- list': 0.33; 'likely': 0.33; 'another': 0.33; 'thanks': 0.34; 'so,': 0.35; 'continue': 0.35; 'but': 0.36; 'anything': 0.36; 'test': 0.36; 'possible': 0.37; 'uses': 0.37; '(for': 0.37; 'subject:: ': 0.38; 'possible.': 0.38; 'to:addr:python.org': 0.39; 'build': 0.39; 'application': 0.40; "you've": 0.61; 'charset:windows-1256': 0.61; 'received:65.55.90': 0.62; 'received:snt0.hotmail.com': 0.62; 'here:': 0.62; 'hear': 0.63; 'more': 0.63; 'else.': 0.65; 'me).': 0.84; 'taken.': 0.84; 'approach.': 0.91; 'safer': 0.91
X-Originating-IP [70.101.97.52]
From Lee Harr <missive@hotmail.com>
To "python-list@python.org" <python-list@python.org>
Subject Re: QThread.terminate in Python 3
Date Sat, 29 Sep 2012 06:34:00 +0430
Importance Normal
Content-Type text/plain; charset="windows-1256"
Content-Transfer-Encoding 8bit
MIME-Version 1.0
X-OriginalArrivalTime 29 Sep 2012 02:04:00.0391 (UTC) FILETIME=[B1291170:01CD9DE6]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1598.1348884309.27098.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348884309 news.xs4all.nl 6971 [2001:888:2000:d::a6]:52430
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30455

Show key headers only | View raw


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

Ok. Point taken.

What I hear you saying is that once I use .terminate anything
following that is indeterminate. It might work on my system
and nowhere else. Even though it was working for me before,
it was likely causing trouble elsewhere.


So, I need another approach.

The problem I am facing is that I want to run arbitrary
(user-supplied) code in the other thread and need to be
able to stop it at any time.

This is for a python turtle-graphics application:
http://pynguin.googlecode.com/


I found another possible approach here:
http://tomerfiliba.com/recipes/Thread2/

It uses ctypes to raise an exception in the other thread.
For the simple test case, at least, it works (for me).

Is this any safer or more reliable than .terminate ?

Is it portable? ie, if I build this in to my actual application
and it works for me, is it likely to work for everyone?


Thanks for any insight.

 		 	   		  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: QThread.terminate in Python 3 Lee Harr <missive@hotmail.com> - 2012-09-29 06:34 +0430

csiph-web