def close_pool():
    global pool
pool.close()
pool.terminate()
pool.join()

def term(*args, **kwargs):
    sys.stderr.write('\nStopping...')
stophttp = threading.Thread(target=httpd.shutdown)
stophttp.start()
stoppool = threading.Thread(target=close_pool)
stoppool.daemon = True
stoppool.start()
signal.signal(signal.SIGTERM, term)
signal.signal(signal.SIGINT, term)
signal.signal(signal.SIGQUIT, term)
Завершение многопроцессорного пула Python