From b88af98e433d0f1233da846304da89abddafc7ac Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Sun, 25 Feb 2018 20:20:37 +0100 Subject: [PATCH] Introduce delay to reduce CPU usage - Telegram "long polling" is a lie :'( --- callmebyyourbot/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/callmebyyourbot/__init__.py b/callmebyyourbot/__init__.py index 3be99b5..3cc452b 100644 --- a/callmebyyourbot/__init__.py +++ b/callmebyyourbot/__init__.py @@ -1,5 +1,6 @@ import sys, random import traceback +from datetime import time from typing import Sequence, AnyStr from depytg import types, methods, errors @@ -94,6 +95,7 @@ def main(): try: while True: prev_offset = mainloop(token, prev_offset) + 1 + time.sleep(0.2) except KeyboardInterrupt: pass