def updateEndpoints( endpointActors, nextUpdate ):
global currentEndpoints
endpointActors.forceRefresh()
responses = endpointActors.requestFromAll( 'report' )
newEndpoints = Set()
while responses.waitForResults( timeout = 10 ):
for response in responses.getNewResults():
if response.isSuccess and 'address' in response.data and 'port' in response.data:
newEndpoints.add( ( response.data[ 'address' ], response.data[ 'port' ] ) )
if responses.isFinished(): break
currentEndpoints = newEndpoints
tmpUpdate = nextUpdate
if 0 == len( currentEndpoints ):
tmpUpdate = 5
print( "Updated list of endpoints, found %s" % len( currentEndpoints ) )
gevent.spawn_later( tmpUpdate, updateEndpoints, endpointActors, nextUpdate )
评论列表
文章目录