Inervo / BedethequeKomga

A Metadata Provider for Komga using Bedetheque
15 stars 2 forks source link

[BUG] Read timed out during script execution #7

Closed kesm closed 1 year ago

kesm commented 1 year ago

Describe the bug Sometimes (often lately) I have a timeout when I launch the script

To Reproduce Steps to reproduce the behavior: Run script on one library

Expected behavior Script should work without error or maybe have the possibility to increase timeout?

Logs

>python refreshMetadata.py
2023-10-03 00:20:32,069 - root - INFO - refreshMetadata.py - Starting refresh in Library mode
2023-10-03 00:20:38,566 - root - WARNING - refreshMetadata.py - Mode No proxy requested, delay between each request = 7 seconds
2023-10-03 00:20:38,567 - root - INFO - refreshMetadata.py - Start updating 38 series
2023-10-03 00:20:55,703 - root - INFO - refreshMetadata.py - Successfully update series 1/38 -  Les ignorants
Traceback (most recent call last):
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1378, in getresponse
    response.begin()
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 706, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\packages\six.py", line 770, in reraise
    raise value
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 451, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 340, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.30', port=25600): Read timed out. (read timeout=15)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\kesm\OneDrive\Documents\GitHub\BedethequeKomga\refreshMetadata.py", line 174, in <module>
    refresh_metadata()
  File "C:\Users\kesm\OneDrive\Documents\GitHub\BedethequeKomga\refreshMetadata.py", line 102, in refresh_metadata
    refresh_book_metadata(komga, serie_id, serie_url, proxy = proxy, wait_delay = env.wait_delay)
  File "C:\Users\kesm\OneDrive\Documents\GitHub\BedethequeKomga\refreshMetadata.py", line 111, in refresh_book_metadata
    all_books = komga.get_series_books(series_id)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\OneDrive\Documents\GitHub\BedethequeKomga\komgaApi.py", line 80, in get_series_books
    response = requests.get(
               ^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kesm\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 578, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.1.30', port=25600): Read timed out. (read timeout=15)

Desktop (please complete the following information):

Inervo commented 1 year ago

Hi, It's strange, because the timeout is between the script and Komga itself, and the timeout is defined at 15 seconds, which is supposed to be largely sufficient.. Is the computer / server hosting the script / komga is slow?

I've tried on my side many times in the last hours, never add this issue.

You may try the following modification on your version of the script : Modify the file komgaApi.py : remove all occurrences of , timeout=15 And try running the script again. The timeout shall not occur anymore, or it will mean there's a really really extra dead slow