Bug fix: Thread MSPA update checker, stop hanging up the whole program on slow MSPA

This commit is contained in:
Kiooeht 2011-07-23 12:28:40 -07:00
parent b9a48671fa
commit e420d4e97d

View file

@ -3,6 +3,7 @@
import feedparser import feedparser
import pickle import pickle
import os import os
import threading
from time import mktime from time import mktime
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -12,12 +13,11 @@ class MSPAChecker(QtGui.QWidget):
self.mainwindow = parent self.mainwindow = parent
self.refreshRate = 30 # seconds self.refreshRate = 30 # seconds
self.status = None self.status = None
self.lock = False
self.timer = QtCore.QTimer(self) self.timer = QtCore.QTimer(self)
self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.connect(self.timer, QtCore.SIGNAL('timeout()'),
self, QtCore.SLOT('check_site()')) self, QtCore.SLOT('check_site_wrapper()'))
self.check_site()
self.timer.start(1000*self.refreshRate) self.timer.start(1000*self.refreshRate)
self.lock = False
def save_state(self): def save_state(self):
try: try:
@ -43,12 +43,16 @@ class MSPAChecker(QtGui.QWidget):
msg.show() msg.show()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def check_site(self): def check_site_wrapper(self):
if not self.mainwindow.config.checkMSPA(): if not self.mainwindow.config.checkMSPA():
return return
if self.lock: if self.lock:
return return
print "Checking MSPA updates..." print "Checking MSPA updates..."
s = threading.Thread(target=self.check_site)
s.start()
def check_site(self):
rss = None rss = None
must_save = False must_save = False
try: try: