bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.44k stars 1.46k forks source link

parent death signal with reloader=True #801

Open wumpus opened 9 years ago

wumpus commented 9 years ago

I have a bottle project where the process loads a lot of data. With reloader=True, typing ^C on the bottle process means the memory-heavy child remains alive. And it's holding the port open.

In Linux, this is easy to deal with by using a parent death signal:

libc = ctypes.CDLL("libc.so.6")
# PR_SET_PDEATHSIG = 1
libc.prctl(1, signal.SIGTERM)

That's not very pretty code, sorry, but I think that this would be a good default behavior under Linux.

eric-wieser commented 9 years ago

It'd be great if this could be fixed on windows too - it's driven me mad countless times. Can't python add a shutdown hook to kill the process upon KeyboardInterrupt?