lifetime.py 文件源码

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

项目:aquests 作者: hansroh 项目源码 文件源码
def graceful_shutdown_loop ():
    global _shutdown_phase
    timestamp = time.time()
    timeout = 1.0
    map = asyncore.socket_map   
    while map and _shutdown_phase < 4:
        time_in_this_phase = time.time() - timestamp
        veto = 0
        for fd,obj in list(map.items()):
            try:
                fn = getattr (obj,'clean_shutdown_control')
            except AttributeError:
                pass
            else:
                try:
                    veto = veto or fn (_shutdown_phase, time_in_this_phase)
                except:                 
                    obj.handle_error()

        if veto and time_in_this_phase < _shutdown_timeout:
            poll_fun_wrap (timeout, map)                    
        else:
            _shutdown_phase += 1
            timestamp = time.time()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号