From 02a07e5119b69d01744ee667935d760eb31af70f Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 29 May 2017 03:16:14 +0200 Subject: [PATCH] Asyncore update - default to true (original attempt didn't work correctly) --- src/api.py | 4 ++-- src/bitmessagemain.py | 6 +++--- src/class_singleWorker.py | 12 ++++++------ src/network/stats.py | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/api.py b/src/api.py index ee371b38..212cd278 100644 --- a/src/api.py +++ b/src/api.py @@ -858,7 +858,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): objectType, toStreamNumber, encryptedPayload, int(time.time()) + TTL,'') with shared.printLock: print 'Broadcasting inv for msg(API disseminatePreEncryptedMsg command):', hexlify(inventoryHash) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((toStreamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -908,7 +908,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): objectType, pubkeyStreamNumber, payload, int(time.time()) + TTL,'') with shared.printLock: print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((pubkeyStreamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index ca578c43..e6b8b56b 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -90,7 +90,7 @@ def connectToStream(streamNumber): if streamNumber*2+1 not in knownnodes.knownNodes: knownnodes.knownNodes[streamNumber*2+1] = {} - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): BMConnectionPool().connectToStream(streamNumber) else: for i in range(state.maximumNumberOfHalfOpenConnections): @@ -266,7 +266,7 @@ class Main: singleAPIThread.daemon = True # close the main program even if there are threads left singleAPIThread.start() - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): asyncoreThread = BMNetworkThread() asyncoreThread.daemon = True asyncoreThread.start() @@ -282,7 +282,7 @@ class Main: connectToStream(1) - if not BMConfigParser().safeGetBoolean("network", "asyncore"): + if not BMConfigParser().get("network", "asyncore"): singleListenerThread = singleListener() singleListenerThread.setup(selfInitiatedConnections) singleListenerThread.daemon = True # close the main program even if there are threads left diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index acdf70ae..07c768a4 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -192,7 +192,7 @@ class singleWorker(threading.Thread, StoppableThread): logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash)) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((streamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -286,7 +286,7 @@ class singleWorker(threading.Thread, StoppableThread): logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash)) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((streamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -380,7 +380,7 @@ class singleWorker(threading.Thread, StoppableThread): logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash)) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((streamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -513,7 +513,7 @@ class singleWorker(threading.Thread, StoppableThread): objectType, streamNumber, payload, embeddedTime, tag) PendingUpload().add(inventoryHash) logger.info('sending inv (within sendBroadcast function) for object: ' + hexlify(inventoryHash)) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((streamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -846,7 +846,7 @@ class singleWorker(threading.Thread, StoppableThread): # not sending to a chan or one of my addresses queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr._translate("MainWindow", "Message sent. Waiting for acknowledgement. Sent on %1").arg(l10n.formatTimestamp())))) logger.info('Broadcasting inv for my msg(within sendmsg function):' + hexlify(inventoryHash)) - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((toStreamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( @@ -952,7 +952,7 @@ class singleWorker(threading.Thread, StoppableThread): objectType, streamNumber, payload, embeddedTime, '') PendingUpload().add(inventoryHash) logger.info('sending inv (for the getpubkey message)') - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): queues.invQueue.put((streamNumber, inventoryHash)) else: protocol.broadcastToSendDataQueues(( diff --git a/src/network/stats.py b/src/network/stats.py index 36baf2cb..b348098c 100644 --- a/src/network/stats.py +++ b/src/network/stats.py @@ -15,7 +15,7 @@ lastSentBytes = 0 currentSentSpeed = 0 def connectedHostsList(): - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): retval = [] for i in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values(): if not i.connected: @@ -29,14 +29,14 @@ def connectedHostsList(): return shared.connectedHostsList.items() def sentBytes(): - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): return asyncore.sentBytes else: return throttle.SendThrottle().total def uploadSpeed(): global lastSentTimestamp, lastSentBytes, currentSentSpeed - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): currentTimestamp = time.time() if int(lastSentTimestamp) < int(currentTimestamp): currentSentBytes = asyncore.sentBytes @@ -48,14 +48,14 @@ def uploadSpeed(): return throttle.sendThrottle().getSpeed() def receivedBytes(): - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): return asyncore.receivedBytes else: return throttle.ReceiveThrottle().total def downloadSpeed(): global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): currentTimestamp = time.time() if int(lastReceivedTimestamp) < int(currentTimestamp): currentReceivedBytes = asyncore.receivedBytes @@ -67,7 +67,7 @@ def downloadSpeed(): return throttle.ReceiveThrottle().getSpeed() def pendingDownload(): - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): tmp = {} for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values(): for k in connection.objectsNewToMe.keys(): @@ -77,7 +77,7 @@ def pendingDownload(): return PendingDownloadQueue.totalSize() def pendingUpload(): - if BMConfigParser().safeGetBoolean("network", "asyncore"): + if BMConfigParser().get("network", "asyncore"): return 0 tmp = {} for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():