Made it compatible with gevent 1.0dev version.

This commit is contained in:
linkerlin 2013-06-28 22:26:31 +08:00
parent 284b3a24f7
commit 80e5adad8c

View File

@ -2875,58 +2875,68 @@ class myTableWidgetItem(QTableWidgetItem):
def __lt__(self, other): def __lt__(self, other):
return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject()) return int(self.data(33).toPyObject()) < int(other.data(33).toPyObject())
from threading import Thread
class UISignaler(QThread): class UISignaler(Thread,QThread):
def __init__(self, parent=None): def __init__(self, parent=None):
Thread.__init__(self, parent)
QThread.__init__(self, parent) QThread.__init__(self, parent)
def run(self): def run(self):
while True: while True:
command, data = shared.UISignalQueue.get() try:
if command == 'writeNewAddressToTable': command, data = shared.UISignalQueue.get()
label, address, streamNumber = data if command == 'writeNewAddressToTable':
self.emit(SIGNAL( label, address, streamNumber = data
"writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), label, address, str(streamNumber)) self.emit(SIGNAL(
elif command == 'updateStatusBar': "writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), label, address, str(streamNumber))
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"), data) elif command == 'updateStatusBar':
elif command == 'updateSentItemStatusByHash': self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"), data)
hash, message = data elif command == 'updateSentItemStatusByHash':
self.emit(SIGNAL( hash, message = data
"updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), hash, message) self.emit(SIGNAL(
elif command == 'updateSentItemStatusByAckdata': "updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), hash, message)
ackData, message = data elif command == 'updateSentItemStatusByAckdata':
self.emit(SIGNAL( ackData, message = data
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message) self.emit(SIGNAL(
elif command == 'displayNewInboxMessage': "updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message)
inventoryHash, toAddress, fromAddress, subject, body = data elif command == 'displayNewInboxMessage':
self.emit(SIGNAL( inventoryHash, toAddress, fromAddress, subject, body = data
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.emit(SIGNAL(
inventoryHash, toAddress, fromAddress, subject, body) "displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
elif command == 'displayNewSentMessage': inventoryHash, toAddress, fromAddress, subject, body)
toAddress, fromLabel, fromAddress, subject, message, ackdata = data elif command == 'displayNewSentMessage':
self.emit(SIGNAL( toAddress, fromLabel, fromAddress, subject, message, ackdata = data
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.emit(SIGNAL(
toAddress, fromLabel, fromAddress, subject, message, ackdata) "displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
elif command == 'updateNetworkStatusTab': toAddress, fromLabel, fromAddress, subject, message, ackdata)
self.emit(SIGNAL("updateNetworkStatusTab()")) elif command == 'updateNetworkStatusTab':
elif command == 'incrementNumberOfMessagesProcessed': self.emit(SIGNAL("updateNetworkStatusTab()"))
self.emit(SIGNAL("incrementNumberOfMessagesProcessed()")) elif command == 'incrementNumberOfMessagesProcessed':
elif command == 'incrementNumberOfPubkeysProcessed': self.emit(SIGNAL("incrementNumberOfMessagesProcessed()"))
self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()")) elif command == 'incrementNumberOfPubkeysProcessed':
elif command == 'incrementNumberOfBroadcastsProcessed': self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()"))
self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()")) elif command == 'incrementNumberOfBroadcastsProcessed':
elif command == 'setStatusIcon': self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()"))
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data) elif command == 'setStatusIcon':
elif command == 'rerenderInboxFromLabels': self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data)
self.emit(SIGNAL("rerenderInboxFromLabels()")) elif command == 'rerenderInboxFromLabels':
elif command == 'rerenderSubscriptions': self.emit(SIGNAL("rerenderInboxFromLabels()"))
self.emit(SIGNAL("rerenderSubscriptions()")) elif command == 'rerenderSubscriptions':
elif command == 'removeInboxRowByMsgid': self.emit(SIGNAL("rerenderSubscriptions()"))
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data) elif command == 'removeInboxRowByMsgid':
else: self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data)
sys.stderr.write( else:
'Command sent to UISignaler not recognized: %s\n' % command) sys.stderr.write(
'Command sent to UISignaler not recognized: %s\n' % command)
except Exception,ex:
# uncaught exception will block gevent
import traceback
traceback.print_exc()
traceback.print_stack()
print ex
pass
try: try:
import gevent import gevent
except ImportError as ex: except ImportError as ex: