Skip to content

Commit 5df22b4

Browse files
author
miao.lin
committed
Made gevent happy with PyQt.
1 parent 0aa7efa commit 5df22b4

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/bitmessageqt/__init__.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,22 @@ def run(self):
29272927
else:
29282928
sys.stderr.write(
29292929
'Command sent to UISignaler not recognized: %s\n' % command)
2930+
try:
2931+
import gevent
2932+
except ImportError as ex:
2933+
print "cannot find gevent"
2934+
else:
2935+
def mainloop(app):
2936+
while True:
2937+
app.processEvents()
2938+
while app.hasPendingEvents():
2939+
app.processEvents()
2940+
gevent.sleep()
2941+
gevent.sleep() # don't appear to get here but cooperate again
29302942

2943+
def testprint():
2944+
#print 'this is running'
2945+
gevent.spawn_later(1, testprint)
29312946

29322947
def run():
29332948
app = QtGui.QApplication(sys.argv)
@@ -2946,5 +2961,8 @@ def run():
29462961
myapp.appIndicatorInit(app)
29472962
myapp.ubuntuMessagingMenuInit()
29482963
myapp.notifierInit()
2949-
2950-
sys.exit(app.exec_())
2964+
if gevent is None:
2965+
sys.exit(app.exec_())
2966+
else:
2967+
gevent.joinall([gevent.spawn(testprint), gevent.spawn(mainloop, app)])
2968+
print 'done'

0 commit comments

Comments
 (0)