redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Include a timeout for `session.post` in `sync_execute`

Open mmangus opened this issue 1 year ago • 0 comments

In sync_execute, commands are executed by making requests to the Upstash REST API like this...

response = session.post(url, headers=headers, json=command).json()

...where session is a requests.Session instance.

As indicated by the requests documentation, this call should include a timeout to avoid blocking for long periods in the event of networking trouble:

Nearly all production code should use this parameter [timeout] in nearly all requests. Failure to do so can cause your program to hang indefinitely

For the Redis workloads I typically have, no response from Redis is better than a slow response from Redis. The client should at least allow users to configure a timeout for these requests, and in my opinion should also have a default timeout enabled without user intervention.

mmangus avatar Apr 12 '24 17:04 mmangus