WebFaction
Community site: login faq

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:

          • ~/webapps/mydjango/apache2/bin/restart

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
3135
accept rate: 0%

edited 09 Apr '12, 21:57


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.

touch /path/to/wsgi/file

Doing this should cause django to use new .pyc files.

permanent link

answered 09 Apr '12, 22:07

johns
5.4k312
accept rate: 23%

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
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225
×81
×1

question asked: 09 Apr '12, 21:07

question was seen: 4,139 times

last updated: 09 Apr '12, 23:36

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM