Reputation: 157
I've modified a .py file on a production server and the changes are not being applied. At first I thought this was because the associated .pyc file was not being updated. So I deleted the .pyc
file and tested hoping the .py
file would compile into a new .pyc
file. The applications behavior did not update and a new .pyc
file was not created. This was done based off a previous question.
How is it that the script is executing without generating a new .pyc
file? Here are the two files in question:
-rw-r--r-- 1 ubuntu ubuntu 47872 Jul 13 04:39 admin_email.py
-rw-r--r-- 1 root root 48212 Feb 10 03:12 admin_email.pyc
admin_email.pyc
has been deleted. Only admin_email.py
remains on there server.
Here is the code that is executing the script that has been changed:
from xxx.admin_email import send_email_admins
...
g = lambda x, y, z: send_email_admins(x, y, z)
...
threading.Thread(target=g, args=(order_id, request.user.email, form.cleaned_data)).start()
The application is being served with gunicorn
+ nginx
.
Any ideas on what the issue is? Why is a new .pyc
file being created? More importantly why is the applications behavior not being updated?
Upvotes: 0
Views: 425
Reputation: 3337
Im assuming you're suing wsgi or fcgi - most probably on apache or nginx
With wsgi - normally apache will cache your django for you.
So, you need to tell apache/nginx/server-provider that your django code has changed. The way you do this is by changing the "last edited" meta information of your .wsgi
file. So, you simple do touch /path/to/django.wsgi
and it will normally work.
If you use fcgi, the same thing applies.
Upvotes: 1