在 运行 时间内更改 python 文件安全吗?

Safe to change python file during run time?

我有 python 3 个文件 运行 SVN 部署。基本上 运行 "python3 deploy.py update" 并且会发生以下情况:

  1. 关闭站点

  2. 备份忽略但保护文件

  3. SVN 还原 -R .

  4. SVN更新

  5. 触发任务

  6. 打开网站

这一切听起来简单而合乎逻辑,但我脑子里转过一个念头 "SVN is writing files, including python files and sub module helpers that are trigger the SVN subprocess"

我知道 python 文件被读取和处理,只有通过一些棘手的重新加载才会 python 重新加载。而且我知道如果 SVN 更改 python 源,那么更新只会在下一个 运行 生效。

但问题是"should keep this structure or move file to root and run SVN to be safe side"

适用于 GIT 或任何 python 更改

据我所知,在 python 为 运行ning 时更改 python(即 .py)文件是安全的,在 [=15 创建了 .pyc 文件之后=](即你的情况)。您甚至可以删除 .py 文件和 运行 .pyc 就好了。

另一方面,SVN revert -R . 在这里很危险,因为它会尝试删除 .pyc 文件,所以要么搞砸你的 python,要么自己失败。