summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-12-16 04:59:35 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-12-16 04:59:35 +0000
commit551897b13446426a2533dafdbd2ea2bc4f96b1e5 (patch)
tree4bfe0f6f5c343aefeacb2b6792cbeabe5aa90a59
parentf2e538281175af1618bae6f2312faa0fd6dde7d9 (diff)
downloaddjango-551897b13446426a2533dafdbd2ea2bc4f96b1e5.tar.gz
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
-rw-r--r--django/utils/autoreload.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 04e319c1c7..1edec190d8 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -31,21 +31,24 @@
import os, sys, thread, time
RUN_RELOADER = True
-reloadFiles = []
def reloader_thread():
mtimes = {}
+ win = (sys.platform == "win32")
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):
continue # File might be in an egg, so it can't be reloaded.
- if filename.endswith(".pyc"):
- filename = filename[:-1]
- mtime = os.stat(filename).st_mtime
+ stat = os.stat(filename)
+ mtime = stat.st_mtime
+ if win:
+ mtime -= stat.st_ctime
if filename not in mtimes:
mtimes[filename] = mtime
continue
- if mtime > mtimes[filename]:
+ if mtime != mtimes[filename]:
sys.exit(3) # force reload
time.sleep(1)