Fixed #937 -- autoreload no longer reloads on every request on Windows. Thanks for the patch, Eugene
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1686 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f2e5382811
commit
551897b134
|
@ -31,21 +31,24 @@
|
||||||
import os, sys, thread, time
|
import os, sys, thread, time
|
||||||
|
|
||||||
RUN_RELOADER = True
|
RUN_RELOADER = True
|
||||||
reloadFiles = []
|
|
||||||
|
|
||||||
def reloader_thread():
|
def reloader_thread():
|
||||||
mtimes = {}
|
mtimes = {}
|
||||||
|
win = (sys.platform == "win32")
|
||||||
while RUN_RELOADER:
|
while RUN_RELOADER:
|
||||||
for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())) + reloadFiles:
|
for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())):
|
||||||
|
if filename.endswith(".pyc") or filename.endswith("*.pyo"):
|
||||||
|
filename = filename[:-1]
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
continue # File might be in an egg, so it can't be reloaded.
|
continue # File might be in an egg, so it can't be reloaded.
|
||||||
if filename.endswith(".pyc"):
|
stat = os.stat(filename)
|
||||||
filename = filename[:-1]
|
mtime = stat.st_mtime
|
||||||
mtime = os.stat(filename).st_mtime
|
if win:
|
||||||
|
mtime -= stat.st_ctime
|
||||||
if filename not in mtimes:
|
if filename not in mtimes:
|
||||||
mtimes[filename] = mtime
|
mtimes[filename] = mtime
|
||||||
continue
|
continue
|
||||||
if mtime > mtimes[filename]:
|
if mtime != mtimes[filename]:
|
||||||
sys.exit(3) # force reload
|
sys.exit(3) # force reload
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue