本文介绍了源文件(.py)不编译(.pyc未更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改生产服务器中的一些代码,但是当我测试新的代码时,它不会被执行。我认为问题是当我上传更新的源文件时,它没有被编译成 .pyc 文件。

I'm trying to change some code in a production server, but when I test the new code it's not being executed. I think the issue is that when I upload the updated source file, it is not being compiled into a .pyc file.

-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

从上面的时间戳可以看出,$ $ c> .pyc 文件尚未更新。

As you can see from the timestamps above, the .pyc file has not been updated.

我正确地假设 admin_email中的更改原因.py 没有被应用是因为它没有被编译?如果是这样,有人可以提出一个建议如何让它这样做?可能问题是我需要重新启动服务器?

Am I correct in assuming the reason the changes in admin_email.py are not being applied is because it is not being compiled? If so, can someone please offer a suggestion on how to get it to do so? Could the issue be that I need to restart the server?

推荐答案

重置应用程序可能会做到这一点。因为你使用的是gunic / nginx,我认为你也是supervisord(如果不是这样的话请说,那么我可以更新我的答案也添加)。在这种情况下,您可以执行 sudo suporvisorctl restart< app_name> 重新启动应用程序。

Resetting the application probably does the trick. Since you are using gunicorn/nginx I assume you are also supervisord (if this is not the case please say so, then I can update my answer to also add that). In that case you can do sudo suporvisorctl restart <app_name> to restart the application.

另一个可能的问题在那里,因为无脑编码器 Marius 也表示,似乎应用程序(至少一次)运行作为,您应该避免这种情况。您应该删除 .pyc 文件,并更改应用程序运行的用户。

Another issue that might be there, as brainless coder and Marius also stated, is that it seems the application was (at least once) ran as root, you should avoid this. You should remove the .pyc files and change the user the application runs under.

这篇关于源文件(.py)不编译(.pyc未更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:41