Asyncore update
- default to true (original attempt didn't work correctly)
This commit is contained in:
parent
73c41bff9d
commit
02a07e5119
|
@ -858,7 +858,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
objectType, toStreamNumber, encryptedPayload, int(time.time()) + TTL,'')
|
objectType, toStreamNumber, encryptedPayload, int(time.time()) + TTL,'')
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'Broadcasting inv for msg(API disseminatePreEncryptedMsg command):', hexlify(inventoryHash)
|
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))
|
queues.invQueue.put((toStreamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -908,7 +908,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
objectType, pubkeyStreamNumber, payload, int(time.time()) + TTL,'')
|
objectType, pubkeyStreamNumber, payload, int(time.time()) + TTL,'')
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash)
|
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))
|
queues.invQueue.put((pubkeyStreamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
|
|
@ -90,7 +90,7 @@ def connectToStream(streamNumber):
|
||||||
if streamNumber*2+1 not in knownnodes.knownNodes:
|
if streamNumber*2+1 not in knownnodes.knownNodes:
|
||||||
knownnodes.knownNodes[streamNumber*2+1] = {}
|
knownnodes.knownNodes[streamNumber*2+1] = {}
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
BMConnectionPool().connectToStream(streamNumber)
|
BMConnectionPool().connectToStream(streamNumber)
|
||||||
else:
|
else:
|
||||||
for i in range(state.maximumNumberOfHalfOpenConnections):
|
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.daemon = True # close the main program even if there are threads left
|
||||||
singleAPIThread.start()
|
singleAPIThread.start()
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
asyncoreThread = BMNetworkThread()
|
asyncoreThread = BMNetworkThread()
|
||||||
asyncoreThread.daemon = True
|
asyncoreThread.daemon = True
|
||||||
asyncoreThread.start()
|
asyncoreThread.start()
|
||||||
|
@ -282,7 +282,7 @@ class Main:
|
||||||
|
|
||||||
connectToStream(1)
|
connectToStream(1)
|
||||||
|
|
||||||
if not BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if not BMConfigParser().get("network", "asyncore"):
|
||||||
singleListenerThread = singleListener()
|
singleListenerThread = singleListener()
|
||||||
singleListenerThread.setup(selfInitiatedConnections)
|
singleListenerThread.setup(selfInitiatedConnections)
|
||||||
singleListenerThread.daemon = True # close the main program even if there are threads left
|
singleListenerThread.daemon = True # close the main program even if there are threads left
|
||||||
|
|
|
@ -192,7 +192,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
|
|
||||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -286,7 +286,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
|
|
||||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -380,7 +380,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
|
|
||||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -513,7 +513,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
objectType, streamNumber, payload, embeddedTime, tag)
|
objectType, streamNumber, payload, embeddedTime, tag)
|
||||||
PendingUpload().add(inventoryHash)
|
PendingUpload().add(inventoryHash)
|
||||||
logger.info('sending inv (within sendBroadcast function) for object: ' + hexlify(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))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -846,7 +846,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
# not sending to a chan or one of my addresses
|
# 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()))))
|
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))
|
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))
|
queues.invQueue.put((toStreamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
@ -952,7 +952,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
objectType, streamNumber, payload, embeddedTime, '')
|
objectType, streamNumber, payload, embeddedTime, '')
|
||||||
PendingUpload().add(inventoryHash)
|
PendingUpload().add(inventoryHash)
|
||||||
logger.info('sending inv (for the getpubkey message)')
|
logger.info('sending inv (for the getpubkey message)')
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
else:
|
else:
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
|
|
|
@ -15,7 +15,7 @@ lastSentBytes = 0
|
||||||
currentSentSpeed = 0
|
currentSentSpeed = 0
|
||||||
|
|
||||||
def connectedHostsList():
|
def connectedHostsList():
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
retval = []
|
retval = []
|
||||||
for i in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
for i in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||||
if not i.connected:
|
if not i.connected:
|
||||||
|
@ -29,14 +29,14 @@ def connectedHostsList():
|
||||||
return shared.connectedHostsList.items()
|
return shared.connectedHostsList.items()
|
||||||
|
|
||||||
def sentBytes():
|
def sentBytes():
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
return asyncore.sentBytes
|
return asyncore.sentBytes
|
||||||
else:
|
else:
|
||||||
return throttle.SendThrottle().total
|
return throttle.SendThrottle().total
|
||||||
|
|
||||||
def uploadSpeed():
|
def uploadSpeed():
|
||||||
global lastSentTimestamp, lastSentBytes, currentSentSpeed
|
global lastSentTimestamp, lastSentBytes, currentSentSpeed
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
currentTimestamp = time.time()
|
currentTimestamp = time.time()
|
||||||
if int(lastSentTimestamp) < int(currentTimestamp):
|
if int(lastSentTimestamp) < int(currentTimestamp):
|
||||||
currentSentBytes = asyncore.sentBytes
|
currentSentBytes = asyncore.sentBytes
|
||||||
|
@ -48,14 +48,14 @@ def uploadSpeed():
|
||||||
return throttle.sendThrottle().getSpeed()
|
return throttle.sendThrottle().getSpeed()
|
||||||
|
|
||||||
def receivedBytes():
|
def receivedBytes():
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
return asyncore.receivedBytes
|
return asyncore.receivedBytes
|
||||||
else:
|
else:
|
||||||
return throttle.ReceiveThrottle().total
|
return throttle.ReceiveThrottle().total
|
||||||
|
|
||||||
def downloadSpeed():
|
def downloadSpeed():
|
||||||
global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed
|
global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
currentTimestamp = time.time()
|
currentTimestamp = time.time()
|
||||||
if int(lastReceivedTimestamp) < int(currentTimestamp):
|
if int(lastReceivedTimestamp) < int(currentTimestamp):
|
||||||
currentReceivedBytes = asyncore.receivedBytes
|
currentReceivedBytes = asyncore.receivedBytes
|
||||||
|
@ -67,7 +67,7 @@ def downloadSpeed():
|
||||||
return throttle.ReceiveThrottle().getSpeed()
|
return throttle.ReceiveThrottle().getSpeed()
|
||||||
|
|
||||||
def pendingDownload():
|
def pendingDownload():
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
tmp = {}
|
tmp = {}
|
||||||
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||||
for k in connection.objectsNewToMe.keys():
|
for k in connection.objectsNewToMe.keys():
|
||||||
|
@ -77,7 +77,7 @@ def pendingDownload():
|
||||||
return PendingDownloadQueue.totalSize()
|
return PendingDownloadQueue.totalSize()
|
||||||
|
|
||||||
def pendingUpload():
|
def pendingUpload():
|
||||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
if BMConfigParser().get("network", "asyncore"):
|
||||||
return 0
|
return 0
|
||||||
tmp = {}
|
tmp = {}
|
||||||
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user