mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 00:21:32 +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.observers import Observer
|
||||||
from watchdog.events import FileSystemEventHandler
|
from watchdog.events import FileSystemEventHandler
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class WebideReloadEventHandler(FileSystemEventHandler):
|
|||||||
self.last_call = time()
|
self.last_call = time()
|
||||||
|
|
||||||
def on_modified(self, event):
|
def on_modified(self, event):
|
||||||
if self.limit_rate(): return
|
self.limit_rate()
|
||||||
|
|
||||||
log.debug(event)
|
log.debug(event)
|
||||||
anchor = 'anchor_webide'
|
anchor = 'anchor_webide'
|
||||||
@ -28,7 +28,8 @@ class WebideReloadEventHandler(FileSystemEventHandler):
|
|||||||
since_last_call = time() - self.last_call
|
since_last_call = time() - self.last_call
|
||||||
to_next_call = self.min_interval - since_last_call
|
to_next_call = self.min_interval - since_last_call
|
||||||
self.last_call = time()
|
self.last_call = time()
|
||||||
return to_next_call > 0
|
if to_next_call > 0:
|
||||||
|
sleep(to_next_call)
|
||||||
|
|
||||||
|
|
||||||
class DirectoryMonitor:
|
class DirectoryMonitor:
|
||||||
|
Loading…
Reference in New Issue
Block a user