def shutdown_server_kill_pending_requests(sock, worker_pool, wait_time=2):
 worker_pool.resize(0)
 sock.close()
 active_requests = worker_pool.running()
 LOG.info('Shutting down. Requests left: %s', active_requests)
 if (active_requests > 0):
  eventlet.sleep(wait_time)
 running_corutines = worker_pool.coroutines_running.copy()
 for coro in running_corutines:
  eventlet.greenthread.kill(coro)
 LOG.info('Exiting...')
 raise SystemExit()

def shutdown_server_kill_pending_requests ( sock , worker_pool , wait_time = 2 ) : worker_pool . resize ( 0 ) sock . close ( ) active_requests = worker_pool . running ( ) LOG . info ( 'Shutting down. Requests left: %s' , active_requests ) if ( active_requests > 0 ) : eventlet . sleep ( wait_time ) running_corutines = worker_pool . coroutines_running . copy ( ) for coro in running_corutines : eventlet . greenthread . kill ( coro ) LOG . info ( 'Exiting...' ) raise SystemExit ( )
custom wsgi server shutdown function which gives outgoing requests some time to finish before killing them .