Stephan
Stephan

Reputation: 35

Flask restart / shutdown callback

I’m using Flask on a Raspberry Pi for an IoT application.

My problem is, that I need to cleanly close the connection to my external device before the application is shutdown or restarted by the Flask auto-reloader.

Is there any callback / handler / event / etc. I can use for a clean shutdown? (that also works with the auto-reloader)

Upvotes: 3

Views: 1458

Answers (1)

davidism
davidism

Reputation: 127340

Application shutdown is not part of the WSGI server standard. There is no general way to know when the server stops completely from within the application code.

Upvotes: 2

Related Questions