Skip to content

Closing server in Docker : gracefull shutdown #7571

Answered by Dreamsorcerer
averatio asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think that's a suggestion, that's a copy of a bit of our source code. You shouldn't use the low-level asyncio APIs for general use, and we'd likely have already cancelled the tasks before you could run that anyway.

The only way to reliably achieve it, is to track the tasks you want to keep running (similar to the the websocket example) and await them all in the shutdown handler (also, you probably want to make sure it's the first shutdown handler, to avoid DB etc. being closed before the handlers complete).

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@averatio
Comment options

@Dreamsorcerer
Comment options

@averatio
Comment options

@Dreamsorcerer
Comment options

Answer selected by averatio
@Dreamsorcerer
Comment options

@averatio
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants