X Tutup
Skip to content

Commit 89ecb04

Browse files
committed
Catch URLError while getting updates
1 parent 56ab40d commit 89ecb04

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

telegram/updater.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
except ImportError:
2222
from queue import Queue
2323

24+
try:
25+
from urllib2 import URLError
26+
except ImportError:
27+
from urllib.error import URLError
28+
2429
H = NullHandler()
2530
logging.getLogger(__name__).addHandler(H)
2631

@@ -167,6 +172,8 @@ def _start_polling(self, poll_interval, timeout, network_delay):
167172
self.update_queue.put(te)
168173
sleep(current_interval)
169174

175+
except URLError as e:
176+
self.logger.error("Error while getting Updates: %s" % e)
170177
# increase waiting times on subsequent errors up to 30secs
171178
if current_interval < 30:
172179
current_interval += current_interval / 2

0 commit comments

Comments
 (0)
X Tutup