Commit cd0fb0d3 authored by Romain Courteaud's avatar Romain Courteaud

bot: ajust crawl interval if previous calculation took too much time

parent d59efeb4
...@@ -463,12 +463,20 @@ class WebBot: ...@@ -463,12 +463,20 @@ class WebBot:
self._running = True self._running = True
try: try:
while self._running: while self._running:
previous_time = datetime.datetime.utcnow()
self.iterateLoop() self.iterateLoop()
next_time = datetime.datetime.utcnow()
interval = int(self.config.get("INTERVAL")) interval = int(self.config.get("INTERVAL"))
if interval < 0: if interval < 0:
self.stop() self.stop()
else: else:
time.sleep(interval) time.sleep(
max(
0,
interval
- (next_time - previous_time).total_seconds(),
)
)
except KeyboardInterrupt: except KeyboardInterrupt:
self.stop() self.stop()
except: except:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment