[PyQt] QTerminate and Python libs?

David Cortesi davecortesi at gmail.com
Wed Jan 9 17:03:05 GMT 2013


The doc for QThread.terminate() says its use "is discouraged".

I have a thread that calls urllib2 to read an http page. I am having a
problem where this thread gets hung somewhere in the urllib2 -- remains to
be determined whether in urllib2.urlopen() or in a read() on the resulting
object.

Anyway, I am thinking of implementing a Kill button so the main thread can
stop and recreate the worker threadin case of such a hang. But am puzzled
on several points:

1. Would .terminate of a QThread that is hung within a python lib, actually
achieve anything, i.e. break out of the python hang?

2. If it did exit the python lib code, would it be likely to leave python
itself (or PyQt or Sip) in some bad indeterminate state that would cause
further problems, e.g. when the thread is recreated and calls back into
urllib2?

3. What about QThread.exit() -- I can't figure out if it is meant for
calling from within the thread's code, or from outside it? Would it be of
use in a "kill" situation?

Any input would be helpful, thank you for your time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130109/24101030/attachment.html>


More information about the PyQt mailing list