Skip to content

Instantly share code, notes, and snippets.

@takwas
Created June 5, 2020 01:47
Show Gist options
  • Save takwas/23208b3e7b30828b922137c0369c23d5 to your computer and use it in GitHub Desktop.
Save takwas/23208b3e7b30828b922137c0369c23d5 to your computer and use it in GitHub Desktop.
fastapi_teardown.py
def register_cleanup_hook(app: fastapi.FastAPI):
@app.on_event('shutdown')
async def cleanup_seq_handler():
print('Worker shutting down. Cleaning up ...')
logger.info('Worker shutting down. Cleaning up ...')
# do some cleanup ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment