0

I am using Cherrypy framework for some simple REST based apps. IF the server is being closed down, either by the operator or by the OS, I want to be able to run a function to clean up the environmental setup for that session. In many cases you can do this on startup, by in this case there is hardware that I want to close down.

In the documentation I could not find anyway to catch a signal that the server is closing down and run some code

1 Answers1

0

I have just stumbled into a similar problem and this SO answer, together with the CherryPy docs on Plugins took me in the right direction: you should write a Plugin, very similar to the example in the docs, and then subscribe the Plugin registering it to the bus before starting the server engine.

Disclaimer: I'm pretty new to CherryPy, so my terminology might be inappropriate or even wrong.

charlie80
  • 806
  • 1
  • 7
  • 17