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:
self._running = True
try:
while self._running:
previous_time = datetime.datetime.utcnow()
self.iterateLoop()
next_time = datetime.datetime.utcnow()
interval = int(self.config.get("INTERVAL"))
if interval < 0:
self.stop()
else:
time.sleep(interval)
time.sleep(
max(
0,
interval
- (next_time - previous_time).total_seconds(),
)
)
except KeyboardInterrupt:
self.stop()
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