def lifetime_loop(): # The main loop. Stay in here until we need to shutdown map = asyncore.socket_map timeout = 30.0 while map and _shutdown_phase == 0: asyncore.poll(timeout, map)