Django wsgi.py更改监视器检测到没有进行任何更改

时间:2013-06-05 11:51:49

标签: python django

我正在Windows机器上开发基于django的站点,但我将我的更改推送到无头Ubuntu服务器以进行暂存。当我将更改拉到登台服务器上的工作目录时,我需要运行manage.py collectstatic。但是,当我这样做时,更改监视器(Reloading Source Code的'监视代码更改'部分)报告它已检测到已更改的文件:

monitor (pid=26216): Starting change monitor.

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: monitor (pid=26216): Change detected to 'myproject/manage.py'.
monitor (pid=26216): Triggering process restart.
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in handle
    return self.handle_noargs(**options)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 160, in handle_noargs
    % (destination_display, clear_display))
KeyboardInterrupt

我运行'touch myproject / wsgi.py'来“更新更改缓存”,然后再次运行collectstatic命令。这导致了同样的错误。

然后我进入python控制台并手动运行监视器启动命令:

import myproject.monitor
myproject.monitor.start(1)

这没有任何区别。我还尝试向监视器添加一个条件,以便在检查文件更改时忽略manage.py但这只是给了我同样的错误,myproject / __ init__.py是它报告已更改的文件。有人知道造成这种情况的原因吗?

1 个答案:

答案 0 :(得分:0)

我找出了造成这种情况的原因。遗留文件修改时间在字典中保存为具有小数位的unix时间戳(例如1366283624.92),而实际修改时间由os.stat(path).st_mtime作为整数返回。我所要做的就是在第54行编辑监视器脚本,改变:

if mtime != _times[path]:

if int(mtime) != int(_times[path]):

我希望这不会导致任何进一步的问题