bboe / farcy

A code review bot for github pull requests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

requests.exceptions.ReadTimeout: Read timed out.

balloob opened this issue · comments

I received this exception which caused Farcy to crash. I know you've added some wrapper around the event loop in #97 but this one doesn't seem to be caught. Do you think we should catch it to prevent internet hiccups from hitting us?

Traceback (most recent call last):
  File "/usr/local/bin/farcy", line 9, in <module>
    load_entry_point('farcy==1.1', 'console_scripts', 'farcy')()
  File "/usr/local/lib/python3.4/dist-packages/farcy/__init__.py", line 409, in main
    Farcy(config).run()
  File "/usr/local/lib/python3.4/dist-packages/farcy/__init__.py", line 378, in run
    for event in self.events():
  File "/usr/local/lib/python3.4/dist-packages/farcy/__init__.py", line 266, in events
    newest_id = self._event_loop(itr, events)
  File "/usr/local/lib/python3.4/dist-packages/farcy/__init__.py", line 141, in _event_loop
    for event in itr:
  File "/usr/local/lib/python3.4/dist-packages/github3/structs.py", line 67, in __iter__
    headers=headers)
  File "/usr/local/lib/python3.4/dist-packages/github3/models.py", line 185, in _get
    return self.session.get(url, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/github3/session.py", line 88, in request
    response = super(GitHubSession, self).request(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 449, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.github.com', port=443): Read timed out. (read timeout=None)

Yes, perhaps there is a more general requests exception that we can handle to get them all.

All exceptions that Requests explicitly raises inherit from requests.exceptions.RequestException.

I actually wonder if this is something that should be fixed upstream in github3.py. I would expect it to catch ReadTimeout and raise ClientError .

I filed an issue. ClientError wouldn't be the right exception to raise as that corresponds to 400-type responses from github. TCP or general networking failures might benefit from having their own exception class.

PR for github3.py to resolve the issue: sigmavirus24/github3.py#598

This issue is likely resolved with the update to github3.py >= 1.0.