-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
httpx.ReadTimeout: The read operation timed out #293
Comments
httpx by default uses What else have you tried? |
@rawandahmad698 As mentioned above I have tried with less items per call as well as more items. I have tried many combinations from 5000 per api call to 50000 per api call. I have also tried different variations of wait time between loops from 0.10 seconds to 3 seconds wait time between each loop. |
I noticed something interesting. This query worked in first go without any timeout existing_search_result = supabase.table('vehicles').select('id', 'ref_id', count='exact').order('id', desc=False).execute()
min_id = existing_search_result.data[-1]['id']
existing_items = existing_search_result.data
total_existing_items = existing_search_result.count
while len(existing_items) < total_existing_items:
try:
existing_items += (
supabase.table(
'vehicles'
).select('id', 'ref_id')
.order('id', desc=False)
.gte('id', min_id)
.execute()
).data
min_id = existing_items[-1]['id']
except Exception as e:
logging.exception(e)
time.sleep(0.30) |
I'm also running some tests with the range filter, thanks for opening this issue. |
I am also getting the # prepare new data
result = df.round(1).to_json(orient="records")
parsed = json.loads(result)
# pprint(parsed)
# upsert fresh data
data = client.table(table_name).upsert(parsed).execute()
# delete any rows that are not in the new data
res = client.table(table_name).select("*").execute()
df = pd.json_normalize(res.data)
ids = df[id_col].unique()
for i in ids:
if i not in df[id_col].unique():
client.from_(table_name).delete().match({id_col: i}).execute() My error log looks similar to the OP's: Traceback (most recent call last):
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/backends/sync.py", line 26, in read
return self._sock.recv(max_bytes)
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1259, in recv
return self.read(buflen)
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1132, in read
return self._sslobj.read(len)
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request
raise exc
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request
response = connection.handle_request(request)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 90, in handle_request
return self._connection.handle_request(request)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/http11.py", line 105, in handle_request
raise exc
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/http11.py", line 84, in handle_request
) = self._receive_response_headers(**kwargs)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/http11.py", line 148, in _receive_response_headers
event = self._receive_event(timeout=timeout)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_sync/http11.py", line 177, in _receive_event
data = self._network_stream.read(
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/backends/sync.py", line 24, in read
with map_exceptions(exc_map):
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpcore/_exceptions.py", line 12, 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 "/Users/xxx/xxx/xxx/xxx/store.py", line 166, in <module>
store_port()
File "/Users/xxx/xxx/xxx/xxx/store.py", line 48, in store_port
sp.upsert_df_to_supabase(df=df_out, id_col="symbol", table_name="holdings")
File "/Users/xxx/xxx/xxx/xxx/cio_data/common/supabase_model.py", line 74, in upsert_df_to_supabase
data = client.table(table_name).upsert(parsed).execute()
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/postgrest/_sync/request_builder.py", line 53, in execute
r = self.session.request(
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_client.py", line 815, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_client.py", line 902, in send
response = self._send_handling_auth(
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_client.py", line 930, in _send_handling_auth
response = self._send_handling_redirects(
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_client.py", line 967, in _send_handling_redirects
response = self._send_single_request(request)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1003, in _send_single_request
response = transport.handle_request(request)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 217, in handle_request
with map_httpcore_exceptions():
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/Users/xxx/xxx/xxx/xxx/.venv/lib/python3.10/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
EDIT: Restarting the project no longer works to prevent this error. |
@rawandahmad698 are you sure the timeout setting is timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT, From DEFAULT_POSTGREST_CLIENT_TIMEOUT = 5 |
I increased timeout to fix it: from supabase import create_client, Client
from supabase.lib.client_options import ClientOptions
supabase_url = os.environ.get('SUPABASE_URL')
supabase_key = os.environ.get('SUPABASE_KEY')
client_options = ClientOptions(timeout=60)
supabase: Client = create_client(supabase_url, supabase_key, options=client_options) Maybe it could help you. |
Need to add https://github.com/supabase-community/supabase-py/blob/develop/supabase/client.py#L91 |
As @starascendin pointed out, the timeout option is currently being ignored in the client. Please add the timeout parameter when calling |
Hey team, Thanks for flagging this! I've added the timeout option and will test it when a slot frees up - in the meantime, if anyone is readily set up to do this could I trouble you to see if configuring the timeout fixes the issue? Thanks! |
Hm, I pulled the latest develop (commit abd1abb) and tested it like so:
The sign_up() call takes longer than 1 second, however I'm not getting a timeout. Either I'm not setting it correctly or it's still not working yet. |
This issue is stale because it has been open for 365 days with no activity. |
Describe the bug
I have 375000 items in my table.
I am doing a loop to obtain all id of all items, with API limit set to 20000 items per api call.
After 200000 I always start to get
httpx.ReadTimeout: The read operation timed out
sometime it may reach 240000 but never go ahead.Error log
The text was updated successfully, but these errors were encountered: