def run(self):
files = dict()
for module in list(sys.modules.values()):
path = getattr(module, '__file__', '')
if path[-4:] in ('.pyo', '.pyc'):
path = path[:-1]
if path and os.path.exists(path):
files[path] = os.stat(path).st_mtime
while not self.status:
if not os.path.exists(self.lockfile) or \
os.stat(self.lockfile).st_mtime < time.time() - self.interval - 5:
self.status = 'error'
_thread.interrupt_main()
for path, last_mtime in files.items():
if not os.path.exists(path) or os.stat(path).st_mtime > last_mtime:
self.status = 'reload'
_thread.interrupt_main()
break
time.sleep(self.interval)
评论列表
文章目录