webhookhandler: Fix exception thrown during error handling (#985)

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, causing the webhook
thread to quit.

Fixes #970
This commit is contained in:
Noam Meltzer 2018-01-25 10:42:48 +02:00 committed by GitHub
parent d6b47da593
commit 8690ba256e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,12 +62,17 @@ class WebhookServer(BaseHTTPServer.HTTPServer, object):
def shutdown(self):
with self.shutdown_lock:
if not self.is_running:
self.logger.warn('Webhook Server already stopped.')
self.logger.warning('Webhook Server already stopped.')
return
else:
super(WebhookServer, self).shutdown()
self.is_running = False
def handle_error(self, request, client_address):
"""Handle an error gracefully."""
self.logger.debug('Exception happened during processing of request from %s',
client_address, exc_info=True)
# WebhookHandler, process webhook calls
# Based on: https://github.com/eternnoir/pyTelegramBotAPI/blob/master/