Asyncore update
- Network status UI works but current speed isn't implemented yet - Track per connection and global transferred bytes - Add locking to write queue so that other threads can put stuff there - send ping on timeout (instead of closing the connection) - implement open port checker (untested, never triggered yet) - error handling on IOmaster
parent
edcba9982b
commit
9683c879bc
@ -1,11 +1,16 @@
|
||||
from queues import Queue
|
||||
import random
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
import knownnodes
|
||||
from queues import portCheckerQueue
|
||||
import state
|
||||
|
||||
def chooseConnection(stream):
|
||||
if state.trustedPeer:
|
||||
return state.trustedPeer
|
||||
else:
|
||||
return random.choice(knownnodes.knownNodes[stream].keys())
|
||||
try:
|
||||
return portCheckerQueue.get(False)
|
||||
except Queue.Empty:
|
||||
return random.choice(knownnodes.knownNodes[stream].keys())
|
||||
|
@ -0,0 +1,43 @@
|
||||
from bmconfigparser import BMConfigParser
|
||||
from network.connectionpool import BMConnectionPool
|
||||
import asyncore_pollchoose as asyncore
|
||||
import shared
|
||||
import throttle
|
||||
|
||||
def connectedHostsList():
|
||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
||||
retval = []
|
||||
for i in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||
if not i.connected:
|
||||
continue
|
||||
try:
|
||||
retval.append((i.destination, i.streams[0]))
|
||||
except AttributeError:
|
||||
pass
|
||||
return retval
|
||||
else:
|
||||
return shared.connectedHostsList.items()
|
||||
|
||||
def sentBytes():
|
||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
||||
return asyncore.sentBytes
|
||||
else:
|
||||
return throttle.SendThrottle().total
|
||||
|
||||
def uploadSpeed():
|
||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
||||
return 0
|
||||
else:
|
||||
return throttle.sendThrottle().getSpeed()
|
||||
|
||||
def receivedBytes():
|
||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
||||
return asyncore.receivedBytes
|
||||
else:
|
||||
return throttle.ReceiveThrottle().total
|
||||
|
||||
def downloadSpeed():
|
||||
if BMConfigParser().safeGetBoolean("network", "asyncore"):
|
||||
return 0
|
||||
else:
|
||||
return throttle.ReceiveThrottle().getSpeed()
|
Loading…
Reference in New Issue