Skip to content

Commit 010024f

Browse files
committed
webhookhandler: Fix exception thrown during error handling
BaseServer.handle_error() default behaviour is to print to stdout or stderr (depends on the python version). In case that the file descriptor is closed an additional exception will be raised, resulting with the webhook thread to quit. Fixes python-telegram-bot#970
1 parent 820f4e1 commit 010024f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

telegram/utils/webhookhandler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ def serve_forever(self, poll_interval=0.5):
6262
def shutdown(self):
6363
with self.shutdown_lock:
6464
if not self.is_running:
65-
self.logger.warn('Webhook Server already stopped.')
65+
self.logger.warning('Webhook Server already stopped.')
6666
return
6767
else:
6868
super(WebhookServer, self).shutdown()
6969
self.is_running = False
7070

71+
def handle_error(self, request, client_address):
72+
"""Handle an error gracefully."""
73+
self.logger.debug('Exception happened during processing of request from %s',
74+
client_address, exc_info=True)
75+
7176

7277
# WebhookHandler, process webhook calls
7378
# Based on: https://github.com/eternnoir/pyTelegramBotAPI/blob/master/

0 commit comments

Comments
 (0)