Ticket #937: django.autoreload.patch
File django.autoreload.patch, 1.3 KB (added by , 19 years ago) |
---|
-
autoreload.py
31 31 import os, sys, thread, time 32 32 33 33 RUN_RELOADER = True 34 reloadFiles = []35 34 36 35 def reloader_thread(): 37 36 mtimes = {} 37 win = (sys.platform == "win32") 38 38 while RUN_RELOADER: 39 for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())) + reloadFiles: 39 for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())): 40 if filename.endswith(".pyc") or filename.endswith("*.pyo"): 41 filename = filename[:-1] 40 42 if not os.path.exists(filename): 41 43 continue # File might be in an egg, so it can't be reloaded. 42 if filename.endswith(".pyc"): 43 filename = filename[:-1] 44 mtime = os.stat(filename).st_mtime 44 stat = os.stat(filename) 45 mtime = stat.st_mtime 46 if win: 47 mtime -= stat.st_ctime 45 48 if filename not in mtimes: 46 49 mtimes[filename] = mtime 47 50 continue 48 if mtime >mtimes[filename]:51 if mtime != mtimes[filename]: 49 52 sys.exit(3) # force reload 50 53 time.sleep(1) 51 54