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


Groups > comp.lang.python > #29820

QThread.terminate in Python 3

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'linux,': 0.05; '(python,': 0.07; '__name__': 0.07; 'problem:': 0.07; 'python': 0.09; '#print': 0.09; '__future__': 0.09; 'etc).': 0.09; 'def': 0.10; 'yet.': 0.13; "'__main__':": 0.16; '2.7.3': 0.16; 'bug,': 0.16; 'hi;': 0.16; 'pointers.': 0.16; 'pyqt,': 0.16; 'qt,': 0.16; 'run(self):': 0.16; "started')": 0.16; 't.start()': 0.16; 'true:': 0.16; 'previously': 0.18; 'code.': 0.20; 'to:name :python-list@python.org': 0.20; 'import': 0.21; 'terminate': 0.22; 'skip:# 10': 0.27; 'sleep': 0.29; 'terminating': 0.29; 'class': 0.29; 'worked': 0.30; 'code': 0.31; 'problem.': 0.32; 'running': 0.32; 'asked': 0.33; 'certain': 0.33; 'ubuntu': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'program,': 0.34; 'thanks': 0.34; 'requiring': 0.35; 'so,': 0.35; 'continue': 0.35; 'there': 0.35; 'but': 0.36; 'test': 0.36; 'should': 0.36; 'possible.': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'where': 0.40; 'charset:windows-1256': 0.61; 'received:65.55.90': 0.62; 'received:snt0.hotmail.com': 0.62; 'here': 0.65; 'hoping': 0.72; "'test'": 0.84; '12.4': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; 'received:65.55.90.7': 0.93
X-Originating-IP [70.101.97.52]
From Lee Harr <missive@hotmail.com>
To "python-list@python.org" <python-list@python.org>
Subject QThread.terminate in Python 3
Date Sun, 23 Sep 2012 20:39:11 +0430
Importance Normal
Content-Type text/plain; charset="windows-1256"
Content-Transfer-Encoding 8bit
MIME-Version 1.0
X-OriginalArrivalTime 23 Sep 2012 16:09:11.0518 (UTC) FILETIME=[C4DE77E0:01CD99A5]
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.1123.1348416619.27098.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348416619 news.xs4all.nl 6915 [2001:888:2000:d::a6]:34339
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29820

Show key headers only | View raw


Hi;

I have asked this on the PyQt list, but have not seen any
response yet. Hoping someone will be able to test this
on their system to see if they see the same problem.

The problem I am seeing is that terminating a QThread running
certain code will freeze the program, requiring it to be kill'd.

Adding a sleep will allow the QThread to be terminated, but
for my use I need to be able to terminate any arbitrary code.
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.

I see the problem on Python 3.2.3 with PyQt 4.9.1 on Ubuntu 12.4

With Python 2.7.3 with PyQt 4.9.1 there is no problem.

I am hoping to find out if this is a bug, and if so, where
I should report it (Python, PyQt, Qt, Linux, etc).

Thanks for any pointers.



Here is a program that shows the problem:


# test_qthread.py

#from __future__ import print_function

import time
from PyQt4 import QtCore


class CmdThread(QtCore.QThread):
    def run(self):
        while True:
            #print 'test'
            print('test')
            #time.sleep(0.2)


if __name__ == '__main__':
    t = CmdThread()
    print('thread set up')
    t.start()
    print('thread started')
    time.sleep(1)
    print('terminating thread')
    t.terminate()
    print('terminated')
    time.sleep(1)
    print('thread is running:', t.isRunning())

 		 	   		  

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


Thread

QThread.terminate in Python 3 Lee Harr <missive@hotmail.com> - 2012-09-23 20:39 +0430

csiph-web