supabase / supabase-py

Python Client for Supabase. Query Postgres from Flask, Django, FastAPI. Python user authentication, security policies, edge functions, file storage, and realtime data streaming. Good first issue.
https://supabase.com/docs/reference/python
MIT License
1.66k stars 194 forks source link

httpx.ReadTimeout: The read operation timed out #510

Closed ishaqmahsud closed 2 months ago

ishaqmahsud commented 1 year ago

Describe the bug to call vector search on 73k records supabase (python) failed due timeout error. please put option developer can increase or decrease timeout according situation. otherwise python library not worthful.

To Reproduce the error can be produce to make embedding to search in huge records about 73k.

Expected behavior i need to increate the timeout for the rpc method so it can easily with failed. in JavaScript its working where it can takes 25 to 30 secs in python it failed.

Screenshots Traceback (most recent call last): File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_transports\default.py", line 60, in map_httpcore_exceptions yield File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_transports\default.py", line 218, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\connection_pool.py", line 253, in handle_request raise exc File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\connection_pool.py", line 237, in handle_request response = connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\connection.py", line 90, in handle_request return self._connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\http11.py", line 112, in handle_request raise exc File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\http11.py", line 91, in handle_request ) = self._receive_response_headers(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\http11.py", line 155, in _receive_response_headers event = self._receive_event(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_sync\http11.py", line 191, in _receive_event data = self._network_stream.read( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore\backends\sync.py", line 26, in read with map_exceptions(exc_map): File "C:\Users\ishaq\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "F:\fielder\textkernelfunc\Lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions raise to_exc(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 "F:\fielder\textkernelfunc\dbhelper.py", line 249, in rs = asyncio.run(job.getTopJobsByCV(tk_res['documentText'])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ishaq\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\ishaq\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ishaq\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\dbhelper.py", line 239, in getTopJobsByCV response = self.connection.rpc('match_jobs', rpc_params).execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\postgrest_sync\request_builder.py", line 55, in execute r = self.session.request( ^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_client.py", line 821, in request return self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_client.py", line 908, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_client.py", line 936, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_client.py", line 973, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_client.py", line 1009, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_transports\default.py", line 217, in handle_request with map_httpcore_exceptions(): File "C:\Users\ishaq\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "F:\fielder\textkernelfunc\Lib\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout: The read operation timed out

Desktop (please complete the following information):

macrochel commented 1 year ago
from supabase import create_client, Client
from supabase.lib.client_options import ClientOptions

client_options = ClientOptions(postgrest_client_timeout=None)
supabase: Client = create_client(url, key, options=client_options)
m3hari commented 10 months ago

+1 Supabse starts throwing this error out of nowhere; we don't have any change. Maybe the size of the table is affecting

git-shogg commented 7 months ago
from supabase import create_client, Client
from supabase.lib.client_options import ClientOptions

client_options = ClientOptions(postgrest_client_timeout=None)
supabase: Client = create_client(url, key, options=client_options)

For the above workaround I am receiving the error below: TypeError: ClientOptions.__init__() got an unexpected keyword argument 'DEFAULT_POSTGREST_CLIENT_TIMEOUT'

Any ideas on this one?

silentworks commented 2 months ago

We've made some changes to the library to increase the timeout that should fix this issue. Closing this for now but if the issue persists please comment for me to reopen this issue.