mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-26 06:01:33 +00:00
Improve webide refresh trigger rate limiting
This commit is contained in:
parent
dceb4b2b7e
commit
4d49c8d11b
@ -1,4 +1,4 @@
|
||||
from time import time
|
||||
from time import time, sleep
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
@ -17,7 +17,7 @@ class WebideReloadEventHandler(FileSystemEventHandler):
|
||||
self.last_call = time()
|
||||
|
||||
def on_modified(self, event):
|
||||
if self.limit_rate(): return
|
||||
self.limit_rate()
|
||||
|
||||
log.debug(event)
|
||||
anchor = 'anchor_webide'
|
||||
@ -28,7 +28,8 @@ class WebideReloadEventHandler(FileSystemEventHandler):
|
||||
since_last_call = time() - self.last_call
|
||||
to_next_call = self.min_interval - since_last_call
|
||||
self.last_call = time()
|
||||
return to_next_call > 0
|
||||
if to_next_call > 0:
|
||||
sleep(to_next_call)
|
||||
|
||||
|
||||
class DirectoryMonitor:
|
||||
|
Loading…
Reference in New Issue
Block a user