Skip to content

httplib exceptions #153

Description

@rahiel

Running my bot continuously, I sometimes get rare exceptions. This traceback was with Python 2.7 and python-telegram-bot 3.2:

  File "/home/rahiel/BismillahBot/bismillah.py", line 99, in send_quran  
    bot.sendMessage(chat_id=chat_id, text=text)
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/bot.py", line 127, in decorator  
    result = func(self, *args, **kwargs)  
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/bot.py", line 159, in decorator  
    result = request.post(url, data)  
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/utils/request.py", line 67, in decorator  
    return func(*args, **kwargs)  
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/utils/request.py", line 140, in post  
    result = urlopen(request, timeout=timeout).read()  
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen  
    return _opener.open(url, data, timeout)  
  File "/usr/lib/python2.7/urllib2.py", line 404, in open  
    response = self._open(req, data)  
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open  
    '_open', req)  
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain  
    result = func(*args)  
  File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open  
    return self.do_open(httplib.HTTPSConnection, req)  
  File "/usr/lib/python2.7/urllib2.py", line 1187, in do_open  
    r = h.getresponse(buffering=True)  
  File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse  
    response.begin()  
  File "/usr/lib/python2.7/httplib.py", line 415, in begin  
    version, status, reason = self._read_status()  
  File "/usr/lib/python2.7/httplib.py", line 379, in _read_status  
    raise BadStatusLine(line)  
httplib.BadStatusLine: ''  

Using version 2.9 of the library I got this traceback in the past:

  File "/home/rahiel/BismillahBot/bismillah.py", line 122, in upload
    v = bot.sendAudio(audio=f, **kwargs)["audio"]["file_id"]
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/bot.py", line 126, in decorator
    result = func(self, *args, **kwargs)
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/bot.py", line 158, in decorator
    result = request.post(url, data)
  File "/home/rahiel/BismillahBot/venv/local/lib/python2.7/site-packages/telegram/utils/request.py", line 108, in post
    message = _parse(error.read())
  File "/usr/lib/python2.7/socket.py", line 351, in read
    data = self._sock.recv(rbufsize)
  File "/usr/lib/python2.7/httplib.py", line 549, in read
    return self._read_chunked(amt)
  File "/usr/lib/python2.7/httplib.py", line 603, in _read_chunked
    raise IncompleteRead(''.join(value))
httplib.IncompleteRead: IncompleteRead(0 bytes read)

Maybe we should catch these exceptions and reraise them as a TelegramError for http errors? I was puzzled by the second traceback, because I was getting it frequently, but that stopped since I updated the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions