Skip to content

Commit

Permalink
Merge pull request #39 from jonas-w/feat/fix_timeout
Browse files Browse the repository at this point in the history
fix None timeout issues
  • Loading branch information
koenvo authored Nov 16, 2023
2 parents d81c625 + 5f9ce71 commit 2465ed1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyodide_http/_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ def send(self, request, **kwargs):
stream = kwargs.get("stream", False)
pyodide_request = Request(request.method, request.url)
pyodide_request.timeout = kwargs.get("timeout", 0)
if type(pyodide_request.timeout) is tuple:
pyodide_request.timeout = pyodide_request.timeout[0] + pyodide_request.timeout[1] if 1 < len(pyodide_request.timeout[1]) else 0
if isinstance(pyodide_request.timeout, tuple):
if len(pyodide_request.timeout) > 1:
pyodide_request.timeout = (pyodide_request.timeout[0] or 0) + (
pyodide_request.timeout[1] or 0
)
elif len(pyodide_request.timeout) > 0:
pyodide_request.timeout = pyodide_request.timeout[0] or 0
if not pyodide_request.timeout:
pyodide_request.timeout = 0
pyodide_request.params = None # this is done in preparing request now
Expand Down

0 comments on commit 2465ed1

Please sign in to comment.