Skip to content

ResourcesBot: Handle aborted connections more graceful #90

@holybiber

Description

@holybiber

Unstable internet connection can cause ResourcesBot to abort by throwing the following error - catch this error and handle the situation better.

2023-04-28 13:23:20,279 root ERROR: Exiting because of uncaught exception: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2023-04-28 13:23:20,281 root ERROR: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 285, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "~/.local/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 285, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "resourcesbot.py", line 135, in
resourcesbot.run()
File "PATH/TO/pywikitools/pywikitools/resourcesbot/bot.py", line 153, in run
consistency_check.run(self._result[lang], self._result["en"], ChangeLog(), ChangeLog())
File "PATH/TO/pywikitools/pywikitools/resourcesbot/consistency_checks.py", line 154, in run
checks_passed += int(self.check_gods_story_titles(language_info))
File "PATH/TO/pywikitools/pywikitools/resourcesbot/consistency_checks.py", line 130, in check_gods_story_titles
self.load_translation_unit(language_info, "God's_Story", self.TITLE),
File "PATH/TO/pywikitools/pywikitools/resourcesbot/consistency_checks.py", line 62, in load_translation_unit
content = self.fortraininglib.get_translated_title(page, language_info.language_code)
File "PATH/TO/pywikitools/pywikitools/fortraininglib.py", line 216, in get_translated_title
return self.get_page_source(f"Translations:{page}/Page display title/{language_code}", revision_id)
File "PATH/TO/pywikitools/pywikitools/fortraininglib.py", line 190, in get_page_source
json = self._get(params)
File "PATH/TO/pywikitools/pywikitools/fortraininglib.py", line 45, in _get
response = self.session.get(self.api_url, params=params, timeout=self.TIMEOUT)
File "/.local/lib/python3.8/site-packages/requests/sessions.py", line 542, in get
return self.request('GET', url, **kwargs)
File "
/.local/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/.local/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "
/.local/lib/python3.8/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions