From 5df22b4181dea5da0d401c9b2ffd965a29d1c973 Mon Sep 17 00:00:00 2001 From: "miao.lin" Date: Fri, 28 Jun 2013 16:45:03 +0800 Subject: [PATCH] Made gevent happy with PyQt. --- src/bitmessageqt/__init__.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index ce477836..49395ed9 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2927,7 +2927,22 @@ class UISignaler(QThread): else: sys.stderr.write( 'Command sent to UISignaler not recognized: %s\n' % command) +try: + import gevent +except ImportError as ex: + print "cannot find gevent" +else: + def mainloop(app): + while True: + app.processEvents() + while app.hasPendingEvents(): + app.processEvents() + gevent.sleep() + gevent.sleep() # don't appear to get here but cooperate again + def testprint(): + #print 'this is running' + gevent.spawn_later(1, testprint) def run(): app = QtGui.QApplication(sys.argv) @@ -2946,5 +2961,8 @@ def run(): myapp.appIndicatorInit(app) myapp.ubuntuMessagingMenuInit() myapp.notifierInit() - - sys.exit(app.exec_()) + if gevent is None: + sys.exit(app.exec_()) + else: + gevent.joinall([gevent.spawn(testprint), gevent.spawn(mainloop, app)]) + print 'done'