[solved] Worker QThread stops working about 30 secs after main window loses focus
I am trying to get a worker thread doing some routing (takes about 5 min) in a slippy map implemented with PyQt4 (4.10.3) and Qt (4.8.5) on OSX (10.9.2).
Everything is working as long as the main window keeps focus. About 30 secs after the main window loses focus, the thread will stop working. When the main window gets focus again, the thread will continue.
Unfortunately, I did not find any hint why this is happening. Thanks for any suggestions.
widget = MapWidget(self)
def init(self, parent=None):
self.osm = osm(...)
self.run_in_thread(self.osm, self.osm.parse_and_route, self.osm_changed)
def run_in_thread(self, obj, function, callback):
self.thread = PyQt4.QtCore.QThread()
finished = PyQt4.QtCore.pyqtSignal()
def init(self, ...):
app = PyQt4.QtGui.QApplication(sys.argv)
w = MapWindow()
if name == 'main':
Hi and welcome to devnet,
Since you're on Mavericks, you might be "benefiting" from the new App Nap feature.
Have a look at this "thread":http://qt-project.org/forums/viewthread/37750
Hope it helps
Thank you very much! Disabling App Nap for Python with "defaults write org.python.python NSAppSleepDisabled -bool YES" did indeed solve the problem. Thanks again for the quick reply
You're welcome !
Since you have your application working, please update the thread title prepending [solved] so other forum users may know a solution has been found :)