Source code reloader only once in every 5 seconds

This commit is contained in:
shortcutme 2018-11-26 00:13:21 +01:00
parent eecc257822
commit 55e2a2fd5d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -42,9 +42,10 @@ class DebugReloader:
not evt.path or "%s/" % config.data_dir in evt.path or
(not evt.path.endswith("py") and not evt.path.endswith("json")) or
"Test" in evt.path or
time.time() - self.last_chaged < 1
time.time() - self.last_chaged < 5.0
):
return False # Ignore *.pyc changes and no reload within 1 sec
self.last_chaged = time.time()
logging.debug("File changed: %s, cb: %s reloading source code" % (evt.path, self.callback))
time.sleep(0.1) # Wait for lock release
self.callback()
self.last_chaged = time.time()