Django keeps files in cache, deletes view.py and view.pyc, still works

I have inherited a project, which is the site that python / django is running on. I have a problem where I believe Django is keeping files in memcache (maybe).

This is a production server. There is currently no DEV environment (that's a different matter).

I am forced to make a fix for a fixed bug on a live site. BUT any modification of the .py files is not reflected on the site. I can even remove view.py (and view.pyc) entirely and the page loads merrily. I looked at caching ( https://docs.djangoproject.com/en/1.3/topics/cache/ ) and added the appropriate dummycache line:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    }
}

      

I tried to make the cache for 1 second:

CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_SECONDS = 1
CACHE_MIDDLEWARE_ALIAS = 'default'

      

Restarting the nginx service doesn't help. I can run /etc/init.d/nginx restart

, and the original files are still working after changes, or are completely removed. The only thing that makes new files read and recompile in pyc is to restart the entire VPS instance! I can edit templates correctly and the changes are reflected as asap, its only py files are not compiled to pyc.

Some other points:

  • I also tried sudo /etc/init.d/nginx reload

    , no dice.
  • This is an AWS EC2 linux VPS running it python through nginx, not apache
  • I tried touch <project>/wsgi.py

  • Distro is a CentOS 6.5 (Final) release, so I also tried sudo service nginx reload

    and sudo service nginx restart

    .

Can anyone shed some light on this?

Edit: As a test, I just deleted the critical view.py + view.pyc file in a sub-site of the site, after 15 minutes it still works fine.

Edit2: I'm starting to think that I just have to restart nginx in a different way. What should I call? Saving changes in Django with Nginx?

Edit3: Based on the help of IgnacioVazquez-Abrams below, it turns out that it uses uwsgi through ps -ef processes. Then I found that it uses a dispatcher as its manager and all the related conf files look great. Then I just had to restart the supervisor and the BAM files updated instantly. Needless to say, this expanded my linux + python knowledge.

+3


source to share


1 answer


Based on IgnacioVazquez-Abrams help, it turned out that he nginx

used uwsgi

to serve django through ps -ef processes. After discovering that he was using uwsgi and finding the uwsgi config file, I searched for ack

any uwsgi file download links I found in the supervisor conf file.

Then I found that it was used supervisor

as a manager and all the relevant conf files looked great. Then I just had to restart supervisor

and the BAM files were updated instantly. Needless to say, this expanded my linux + python knowledge.



It asks the question, is there an easier way to automatically reload files after a certain period or time, or is this critical to improving the performance of the python / django / nginx / uwsgi stack?

+1


source







All Articles