endpoint_proxy.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:lc_cloud 作者: refractionPOINT 项目源码 文件源码
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 )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号