jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.3k stars 475 forks source link

notion_client.errors.RequestTimeoutError: Request to Notion API has timed out #391

Open noahbuttner opened 1 year ago

noahbuttner commented 1 year ago
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 126, in read
    return self._sock.recv(max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1234, in recv
    return self.read(buflen)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1107, in read
    return self._sslobj.read(len)
           ^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out

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

Traceback (most recent call last):
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
    yield
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_transports/default.py", line 228, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 268, in handle_request
    raise exc
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 251, in handle_request
    response = connection.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 103, in handle_request
    return self._connection.handle_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 133, in handle_request
    raise exc
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 111, in handle_request
    ) = self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 176, in _receive_response_headers
    event = self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 212, in _receive_event
    data = self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 124, in read
    with map_exceptions(exc_map):
  File "/usr/local/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ReadTimeout: The read operation timed out

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

Traceback (most recent call last):
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/notion_client/client.py", line 191, in request
    response = self.client.send(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_client.py", line 901, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_transports/default.py", line 227, in handle_request
    with map_httpcore_exceptions():
  File "/usr/local/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/noahbuttner/Documents/rover/rover/slack/migrate_it.py", line 114, in <module>
    existing_messages = get_existing_messages()
                        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slack/notion_cli.py", line 21, in get_existing_messages
    results = notion.databases.query(
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/notion_client/api_endpoints.py", line 132, in query
    return self.parent.request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahbuttner/Documents/rover/rover/slackenv/lib/python3.12/site-packages/notion_client/client.py", line 193, in request
    raise RequestTimeoutError()
notion_client.errors.RequestTimeoutError: Request to Notion API has timed out

Is there anything I can do to prevent this error from occurring? This seems to happen pretty regularly.