Django cleanup code
In mine, models.py
I am opening some files and database connections. Where can I put the code to ensure that these files / connections are closed when the server shuts down?
+3
tdc
source
to share
1 answer
You can use python with instruction. This allows you to clean up after yourself. That is, the files are closed.
Here's a good tutorial: http://effbot.org/zone/python-with-statement.htm
0
sbaechler
source
to share