Ticket #937: django.autoreload.patch

File django.autoreload.patch, 1.3 KB (added by eugene@…, 19 years ago)
  • autoreload.py

     
    3131import os, sys, thread, time
    3232
    3333RUN_RELOADER = True
    34 reloadFiles = []
    3534
    3635def reloader_thread():
    3736    mtimes = {}
     37    win = (sys.platform == "win32")
    3838    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]
    4042            if not os.path.exists(filename):
    4143                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
    4548            if filename not in mtimes:
    4649                mtimes[filename] = mtime
    4750                continue
    48             if mtime > mtimes[filename]:
     51            if mtime != mtimes[filename]:
    4952                sys.exit(3) # force reload
    5053        time.sleep(1)
    5154
Back to Top