PyQt QThreadPool error

Phil Thompson phil at riverbankcomputing.com
Thu Jan 7 23:02:56 CET 2010


On Thu, 7 Jan 2010 13:03:24 -0800 (PST), h0uk <vardan.pogosyan at gmail.com>
wrote:
> On 8 янв, 01:02, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>> h0uk schrieb:
>>
>>
>>
>> > Hello.
>>
>> > I have the following code:
>>
>> >             #workers = {}
>> >             QtCore.QThreadPool.globalInstance().setExpiryTimeout
>> > (300000)
>> >            
>> > QtCore.QThreadPool.globalInstance().setMaxThreadCount(1)
>> >             for i in range(1, int(userscnt) + 1):
>> >                 work = wk.Worker(i)
>> >                 # connect signals
>> >                
>> > work.mmShowCaptcha.connect(self.show_captcha_dlg)
>> >                 work.log.connect(self.handle_log)
>> >                
>> > self.captcha_answer.connect(work.mmCaptchaAnswer)
>> >                 work.setAutoDelete(True)
>> >                
QtCore.QThreadPool.globalInstance().start(work)
>>
>> > On last line of code ( QtCore.QThreadPool.globalInstance().start
>> > (work) ) i get an error:
>>
>> > SystemError: error return without exception set
>>
>> > What is wrong in my code??? Any advise???
>>
>> The error is on C-level. AFAIK it occurs when a Python-C-function
>> returns "NULL" without setting an exception.
>>
>> It's hard to say where it really occurs. I'd use a debug-build of PyQt,
>> and possibly Python, and then investigate using gdb.
>>
>> Alternatively, what happens when you do some "dummy"-work that doesn't
>> use signals and no other libraries?
>>
>> Diez
> 
> About some "dummy" code:
> 
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> 
> import sys
> import os
> import time
> 
> from PyQt4 import QtCore, QtGui
> 
> class Job(QtCore.QRunnable):
> 	def __init__(self, name):
> 		QtCore.QRunnable.__init__(self)
> 		self._name = name
> 
> 	def run(self):
> 		time.sleep(10)
> 		print self._name
> 
> 	def autoDelete(self):
> 		return self._auto
> 
> 	def setAutoDelete(self, auto):
> 		self._auto = auto
> 
> 
> 
> if __name__ == "__main__":
> 
> 	app = QtGui.QApplication(sys.argv)
> 
> 	QtCore.QThreadPool.globalInstance().setMaxThreadCount(1)
> 
> 	j = Job("Job-1")
> 	j.setAutoDelete(True)
> 	QtCore.QThreadPool.globalInstance().start(j)
> 
> 
> Even this code not work. On the last line of code
> ( QtCore.QThreadPool.globalInstance().start(j) ) i get the error:
> 
>>> An unhandled win32 exception occured in python.exe

You aren't letting the thread run before exiting the program. Try adding...

    app.exec_()

...after you call start().

Also, I'm not sure what you are trying to achieve with your implementations
of autoDelete() and setAutoDelete().

Phil



More information about the Python-list mailing list