Skip to content

TG Error within error Handler clogs the main thread #701

@jeffffc

Description

@jeffffc

Steps to reproduce

  1. Include some bot,* methods within the error handler

  2. When error occurred (maybe regarding to connection with TG server), it falls into the error handler, but the methods inside (for example sendmessage) actually still throws error.

Expected behaviour

Tell us what should happen
re-enter the error handler maybe?

Actual behaviour

Tell us what happens instead
the main thread clogs, keeps getting updates but does not process them

Configuration

Operating System:
ubuntu 16.04

Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 6.1.0
urllib3 1.20
certifi 2017.04.17
future 0.16.0
Python 3.5.2 (default, Nov 17 2016, 17:05:23)  [GCC 5.4.0 20160609]

Logs

(posted in support group already)

2017-06-30 00:01:56,989 - telegram.ext.updater - ERROR - Error while getting Updates: Invalid server response
2017-06-30 00:01:56,989 - telegram.ext.dispatcher - DEBUG - Processing Update: Invalid server response
2017-06-30 00:01:56,990 - telegram.bot - DEBUG - Entering: send_message
2017-06-30 00:01:57,057 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /botTOKEN/sendMessage HTTP/1.1" 502 173
2017-06-30 00:01:57,059 - telegram.ext.updater - ERROR - unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 134, in _parse
    data = json.loads(decoded_s)
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 133, in _thread_wrapper
    target(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/dispatcher.py", line 214, in start
    self.process_update(update)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/dispatcher.py", line 258, in process_update
    self.dispatch_error(None, update)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/dispatcher.py", line 369, in dispatch_error
    callback(self.bot, update, error)
  File "main.py", line 1961, in error
    bot.sendMessage(-1001117997439, "ERROR HAPPENED:\n{}".format(error))
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 52, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 64, in decorator
    return self._message_wrapper(url, data, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 156, in _message_wrapper
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 252, in post
    **urlopen_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 187, in _request_wrapper
    message = self._parse(resp.data)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 136, in _parse
    raise TelegramError('Invalid server response')
telegram.error.TelegramError: Invalid server response

2017-06-30 00:01:57,990 - telegram.bot - DEBUG - Entering: get_updates
2017-06-30 00:02:09,503 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /botTOKEN/getUpdates HTTP/1.1" 200 872
2017-06-30 00:02:09,505 - telegram.bot - DEBUG - Getting updates: [543779844, 543779845]
2017-06-30 00:02:09,506 - telegram.bot - DEBUG - [<telegram.update.Update object at 0xb2fa3510>, <telegram.update.Update object at 0xaffd9eb0>]
2017-06-30 00:02:09,507 - telegram.bot - DEBUG - Exiting: get_updates
2017-06-30 00:02:09,507 - telegram.bot - DEBUG - Entering: get_updates
2017-06-30 00:02:09,730 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /botTOKEN/getUpdates HTTP/1.1" 200 2113
2017-06-30 00:02:09,732 - telegram.bot - DEBUG - Getting updates: [543779846, 543779847, 543779848, 543779849]
2017-06-30 00:02:09,735 - telegram.bot - DEBUG - [<telegram.update.Update object at 0xb2f3e730>, <telegram.update.Update object at 0xaffc8f10>, <telegram.update.Update object at 0xb3822810>, <telegram.update.Update object at 0xb38225f0>]
2017-06-30 00:02:09,735 - telegram.bot - DEBUG - Exiting: get_updates
2017-06-30 00:02:09,736 - telegram.bot - DEBUG - Entering: get_updates
2017-06-30 00:02:09,933 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /botTOKEN/getUpdates HTTP/1.1" 200 5055
2017-06-30 00:02:09,935 - telegram.bot - DEBUG - Getting updates: [543779850, 543779851, 543779852, 543779853, 543779854, 543779855, 543779856, 543779857, 543779858, 543779859, 543779860, 543779861]
2017-06-30 00:02:09,942 - telegram.bot - DEBUG - [<telegram.update.Update object at 0xb2fa87d0>, <telegram.update.Update object at 0xb2fa8330>, <telegram.update.Update object at 0xb2fa8d50>, <telegram.update.Update object at 0xb2fa8f10>, <telegram.update.Update object at 0xb2fa8e90>, <telegram.update.Update object at 0xb2fa87b0>, <telegram.update.Update object at 0xaffffc90>, <telegram.update.Update object at 0xaffffa50>, <telegram.update.Update object at 0xaffffa10>, <telegram.update.Update object at 0xaffff810>, <telegram.update.Update object at 0xaffffe50>, <telegram.update.Update object at 0xaffff230>]
2017-06-30 00:02:09,942 - telegram.bot - DEBUG - Exiting: get_updates```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions