My Django site goes down and gives me a python ImportError for a module I use in my views.py when I attempt to restart apache using any type of cron job. I have tried for example:
I've also tried setting up a python script to run with cron using an os.system(r'./restart') command but I get the same results as the above cron expression. The error is strange to me as a newbie since all of my modules import just fine when I restart apache via a standard command using SSH, i.e. cd webapps/mydjango/apache2/bin ./restart The reason I need to restart apache is because my views use a pickled dictionary which is updated once daily with a file I fetch from an FTP site. So the process downloads the text file, parses the text file into a dictionary and stores the dict as a pickle. I then open the pickle file and load the dictionary into memory to use for my views. The need for the restart is that unless I restart apache, my Django app won't use the most recently downloaded/saved pickle so the restart serves to force Django to load the most recent pickle. I certainly open for suggestions on how to better handle this data persistence problem. although I've considered a Django model, I have reservations regarding the amount of work it will take to create the model and furthermore I'm worried that after all that work I will be tied to the Django model and will lose the portability that the pickle provides. Thanks a ton! asked 09 Apr '12, 21:07 dgre420 |
Sounds like a python sys.path issue. The import error may be caused if you have a virtualenv and are not including the paths correctly. We would need to see the app in real-time to track down the path issue, so you might want to submit a support ticket within the control panel. One thing you could do is to just 'touch' the .wsgi file.
Doing this should cause django to use new .pyc files. answered 09 Apr '12, 22:07 johns Thanks a lot. Didn't know about touch. I'll try it tomorrow once the new file is available on the FTP.
(09 Apr '12, 23:36)
dgre420
|