python运行时修改代码_python – 当其中一个代码文件被更改时,自动Django重新加载的规则是什么?...

我注意到./manage.py runserver会在我的views.py文件发生更改时自动重新加载.如何驱动它的底层代码工作?

解决方法:

自动Django服务器重启:

Django尝试每秒轮询文件修改时间戳.如果它看到有任何变化.它重新启动服务器.

基本上,Django服务器每秒检查每个文件的修改时间戳.如果它看到其中任何一个发生了变化,它将触发服务器重启.

但是,添加新文件不会触发重新启动,因此您必须在该方案中自行重新启动服务器.

例外:如果您使用Linux并安装pyinotify,内核信号将用于自动加载服务器.

If you are using Linux and install pyinotify, kernel signals will be

used to autoreload the server (rather than polling file modification

timestamps each second). This offers better scaling to large projects,

reduction in response time to code modification, more robust change

detection, and battery usage reduction.

重新启动服务器时执行系统检查:

The system check framework is a set of static checks for validating

Django projects. It detects common problems and provides hints for how

to fix them.

当您启动服务器时,每次在服务器运行时更​​改Python代码时,系统检查框架都会检查整个Django项目是否存在常见错误.如果发现任何错误,则将它们打印到标准输出.

标签:python,django

来源: https://codeday.me/bug/20190623/1273101.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值