sadmanca / trakt-randomizer

MIT License
0 stars 0 forks source link

Investigate random infrequent HTTPS read time out errors via the Trakt API #19

Open sadmanca opened 1 year ago

sadmanca commented 1 year ago

When exception occurs, Github Actions builds exit with code 1 (indicates that the command being executed in the Github action has failed).

Exceptions occur in ~1/15 runs.

See:

Example error output:

INFO:root:users/sadmanca/lists/hindi
INFO:root:ORIGINAL:
INFO:root:    <Movie 'Baby' (2015)>
INFO:root:    <Movie 'Khatta Meetha' (2010)>
INFO:root:    ...
INFO:root:    <Movie 'Dil Hai Tumhaara' (2002)>
INFO:root:    <Movie 'Ek Tha Tiger' (2012)>
INFO:root:SHUFFLED:
INFO:root:    <Movie 'Badhaai Ho Badhaai' (2002)>
INFO:root:    <Movie 'Tezz' (2012)>
INFO:root:    ...
INFO:root:    <Movie 'Krrish' (2006)>
INFO:root:    <Movie 'R... Rajkumar' (2013)>
INFO:root:users/sadmanca/lists/best-of-the-2000s
INFO:root:ORIGINAL:
INFO:root:    <Movie 'Where the Wild Things Are' (2009)>
INFO:root:    <Movie 'Cast Away' (2000)>
INFO:root:    ...
INFO:root:    <Movie 'The Village' (2004)>
INFO:root:    <Movie 'In the Bedroom' (2001)>
INFO:root:users/hdlists/lists/best-of-the-00s
INFO:root:NEW, SHUFFLED:
INFO:root:    <Movie 'Shadow of the Vampire' (2000)>
INFO:root:    <Movie 'Inland Empire' (2006)>
INFO:root:    ...
INFO:root:    <Movie 'Cast Away' (2000)>
INFO:root:    <Movie 'Intolerable Cruelty' (2003)>
INFO:root:users/sadmanca/lists/best-of-the-2010s
INFO:root:ORIGINAL:
INFO:root:    <Movie 'Blackfish' (2013)>
INFO:root:    <Movie 'The Descendants' (2011)>
INFO:root:    ...
INFO:root:    <Movie 'X-Men: Days of Future Past' (2014)>
INFO:root:    <Movie 'Side Effects' (2013)>
INFO:root:users/hdlists/lists/best-of-the-2010s
INFO:root:NEW, SHUFFLED:
INFO:root:    <Movie 'Fruitvale Station' (2013)>
INFO:root:    <Movie 'Spider-Man: Homecoming' (2017)>
INFO:root:    ...
INFO:root:    <Movie 'The Perks of Being a Wallflower' (2012)>
INFO:root:    <Movie 'The Beatles: Eight Days a Week - The Touring Years' (2016)>
INFO:root:users/sadmanca/lists/action-movies-top-rated-from-1980-to-today
INFO:root:ORIGINAL:
INFO:root:    <Movie 'The Abyss' (1989)>
INFO:root:    <Movie "Pete's Dragon" (2016)>
INFO:root:    ...
INFO:root:    <Movie 'Clash of the Titans' (1981)>
INFO:root:    <Movie 'Dragonslayer' (1981)>
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connectionpool.py", line 536, in _make_request
    response = conn.getresponse()
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connection.py", line 454, in getresponse
    httplib_response = super().getresponse()
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/http/client.py", line 1377, in getresponse
    response.begin()
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/http/client.py", line 320, in begin
    version, status, reason = self._read_status()
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/http/client.py", line 281, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/ssl.py", line 1242, in recv_into
    return self.read(nbytes, buffer)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/ssl.py", line 1100, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/util/util.py", line 39, in reraise
    raise value
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connectionpool.py", line 538, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/urllib3/connectionpool.py", line 370, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.trakt.tv', port=443): Read timed out. (read timeout=24)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/trakt-randomizer/trakt-randomizer/main.py", line 181, in <module>
    main()
  File "/home/runner/work/trakt-randomizer/trakt-randomizer/main.py", line 177, in main
    multi_run(url_list)
  File "/home/runner/work/trakt-randomizer/trakt-randomizer/main.py", line 167, in multi_run
    copy_run(urlparse(key).path[1:], urlparse(value).path[1:], randomize=True)
  File "/home/runner/work/trakt-randomizer/trakt-randomizer/main.py", line 126, in copy_run
    Trakt[self_list_slug].remove(data)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/interfaces/base/__init__.py", line 126, in wrap
    return value(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/interfaces/base/__init__.py", line 20, in wrap
    return func(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/interfaces/users/lists/list_.py", line 150, in remove
    response = self.http.post(
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/core/http.py", line 188, in post
    return self.request('POST', path, params, data, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/core/http.py", line 121, in request
    return self.send(prepared)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/trakt/core/http.py", line 142, in send
    response = self.session.send(request, timeout=timeout)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.trakt.tv', port=443): Read timed out. (read timeout=24)
Error: Process completed with exit code 1.
sadmanca commented 1 year ago

Current temporary solution: increase time between Github Actions runs to decrease probability of read time out occurring.