manually undid much of pull #287. Discussion in #398 #442

Merged
Atheros1 merged 1 commits from master into master 2013-08-26 01:36:16 +02:00
3 changed files with 46 additions and 118 deletions

View File

@ -9,13 +9,6 @@
# The software version variable is now held in shared.py # The software version variable is now held in shared.py
# import ctypes
try:
from gevent import monkey
monkey.patch_all()
except ImportError as ex:
print "Not using the gevent module as it was not found. No need to worry."
import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully. import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
# The next 3 are used for the API # The next 3 are used for the API
from SimpleXMLRPCServer import * from SimpleXMLRPCServer import *

View File

@ -3333,16 +3333,13 @@ 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:
try:
command, data = shared.UISignalQueue.get() command, data = shared.UISignalQueue.get()
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data label, address, streamNumber = data
@ -3387,26 +3384,6 @@ class UISignaler(Thread,QThread):
else: else:
sys.stderr.write( sys.stderr.write(
'Command sent to UISignaler not recognized: %s\n' % command) '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:
import gevent
except ImportError as ex:
gevent = None
else:
def mainloop(app):
while True:
app.processEvents()
gevent.sleep(0.01)
def testprint():
#print 'this is running'
gevent.spawn_later(1, testprint)
def run(): def run():
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
@ -3443,8 +3420,4 @@ def run():
myapp.notifierInit() myapp.notifierInit()
if shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'): if shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
myapp.showConnectDialog() # ask the user if we may connect myapp.showConnectDialog() # ask the user if we may connect
if gevent is None:
sys.exit(app.exec_()) sys.exit(app.exec_())
else:
gevent.joinall([gevent.spawn(testprint), gevent.spawn(mainloop, app), gevent.spawn(mainloop, app), gevent.spawn(mainloop, app), gevent.spawn(mainloop, app), gevent.spawn(mainloop, app)])
print 'done'

View File

@ -1,38 +0,0 @@
#! /usr/bin/python
# -*- coding: utf-8 -*-
# cody by linker.lin@me.com
__author__ = 'linkerlin'
import threading
import Queue
import time
class bgWorker(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.q = Queue.Queue()
self.setDaemon(True)
def post(self,job):
self.q.put(job)
def run(self):
while 1:
job=None
try:
job = self.q.get(block=True)
if job:
job()
except Exception as ex:
print "Error,job exception:",ex.message,type(ex)
time.sleep(0.05)
else:
#print "job: ", job, " done"
pass
finally:
time.sleep(0.05)
bgworker = bgWorker()
bgworker.start()