PyQt QThreadPool error
h0uk
vardan.pogosyan at gmail.com
Fri Jan 8 12:11:10 EST 2010
On 8 янв, 16:27, Phil Thompson <p... at riverbankcomputing.com> wrote:
> On Thu, 7 Jan 2010 15:07:10 -0800 (PST), h0uk <vardan.pogos... at gmail.com>
> wrote:
>
> ...
>
>
>
> > Phil you right about app.exec_(). But situation is sligthly different.
>
> > I want to have more than one Job. I add these Jobs into QThreadPool
> > trough cycle. And I also want these Jobs to run sequentially.
>
> > The following code illustrate what I mean:
>
> > #!/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(3)
> > print self._name
>
> > if __name__ == "__main__":
>
> > app = QtGui.QApplication(sys.argv)
>
> > QtCore.QThreadPool.globalInstance().setMaxThreadCount(1)
>
> > for i in range(5):
> > j = Job("Job-" + str(i))
> > j.setAutoDelete(True)
> > QtCore.QThreadPool.globalInstance().start(j, i)
> > app.exec_()
>
> > After 5 cycle I get the same error: An unhandled win32 exception
> > occured in python.exe.
>
> > How I can do it?? To run my Jobs sequentially???
>
> It's a PyQt bug. The workaround is not to use setAutoDelete() and instead
> keep an explicit reference to your Job instances - for example in a list of
> jobs.
>
> Phil
Thanks, Phil.
More information about the Python-list
mailing list