[PyQt] Bug Report: QThreadPool doesn't take the ownership of QRunnable
Riccardo Ferrazzo
rferrazz at develer.com
Fri Mar 21 09:43:36 GMT 2014
Hi,
In PyQt5 i'm having problems due to deleted objects inside the QThreadPool.
I've created a simple example to prove the existence of the problem:
from PyQt5.QtCore import *
from time import sleep
class Test(QRunnable):
def __init__(self):
QRunnable.__init__(self)
def run(self):
sleep(10)
print(self, "Awake!")
def __del__(self):
print(self, "Deleted")
def run_thread():
t = Test()
QThreadPool.globalInstance().start(t)
if __name__ == "__main__":
for i in range(10):
run_thread()
sleep(20)
It prints out:
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fcc8>, 'Deleted')
(<__main__.Test object at 0x7feb8499fc30>, 'Awake!')
(<__main__.Test object at 0x7feb8499fc30>, 'Deleted')
(<__main__.Test object at 0x7feb8499fcc8>, 'Awake!')
(<__main__.Test object at 0x7feb8499fcc8>, 'Deleted')
--
Riccardo Ferrazzo
Software Developer
Develer S.r.l. - http://www.develer.com
Tel.: +39 055 3984627 int. 243
More information about the PyQt
mailing list