Not sure about this (never tried), but Python Library Reference says:
Note: the functions registered via this module are not called when
the program is killed by a signal, when a Python fatal internal error
is detected, or when os._exit() is called.
Since Ctrl+C sends a SIGINT to your server
after reading that i thought catch signal?
and then yahoo search said import signal
and someone seems to have worked on the same issue--
http://stevemorin.blogspot.com/2005/11/python-shutdown-hook-method-update.html
from what i've read, you probably want a couple of ways to catch the
exit
Previously Mr.Rech wrote:
Not sure about this (never tried), but Python Library Reference says:
Note: the functions registered via this module are not called when
the program is killed by a signal, when a Python fatal internal error
is detected, or when os._exit() is called.
Since
Hi all,
I was wondering if there were a way to run methods or execute code on
server shutdown (Ctrl+C, or otherwise). I'd like to close a Berkeley
DB environment I'm running so as to avoid a potential nasty bug -- I
tried adding code to the __del__() method of app_globals.py, but it
doesn't
On Oct 8, 2008, at 3:40 PM, Phil Fazio wrote:
I was wondering if there were a way to run methods or execute code on
server shutdown (Ctrl+C, or otherwise). I'd like to close a Berkeley
DB environment I'm running so as to avoid a potential nasty bug -- I
tried adding code to the __del__()
I appreciate your quick response. However, I don't think I'm doing it
right... I tried putting the following code in my
app_globals.Globals.__init__() method:
import atexit
import fooapp.models.database as db
atexit.register(db.close_environment)
where my close_environment() method