[Answered ]-Cleaning up after a python script has been run locally vs from Django

2👍

I don’t know why you find this behaviour hard to explain. A script is run once and then quits, but a server application is persistent, therefore it should not be surprising that global data is persistent within that application.

The solution should be obvious: don’t use global variables. They are rarely helpful, except in the odd cases when you do actually want data to persist between calls. Especially in a server environment, where different users can be requesting a resource at different times, global variables are dangerous. In your case, without seeing the relevant functions within mtcbody it’s hard to advise, but it seems like you should pass around the data within that module, perhaps via a class.

Leave a comment