[PyKDE] Using QThread and qApp.lock
Boudewijn Rempt
boud at valdyas.org
Fri Apr 12 13:10:26 BST 2002
Janez Jere mailed me the other day about using threading in PyQt, and I
found that I couldn't get a working solution myself.
First, qApp.lock() or qApp.unlock() always seems to segfault. Without locking
the application, one shouldn't call methods on QWidgets, of course, so that
will lead to a segfault, too.
Finally, when I run the script without locking, without accessing the GUI, I
can get a working run, sometimes. Look at the result of running thread2.py
three times:
boud at calcifer:~> python thread2.py
0
0
1
1
2
2
3
3
4
4
Fatal Python error: PyEval_RestoreThread: NULL tstate
Aborted
boud at calcifer:~> 5
5
6
boud at calcifer:~> python thread2.py
0
0
Fatal Python error: PyThreadState_Get: no current thread
Fatal Python error: PyThreadState_Get: no current thread
Aborted
boud at calcifer:~> python thread2.py
0
0
Fatal Python error: PyThreadState_Get: no current thread
Aborted
(The first run I pressed ctrl-c to end it.)
--
Boudewijn Rempt | http://www.valdyas.org
More information about the PyQt
mailing list