From 9b02c3763f42053cefa32fdae8b6f6fa3719bbd8 Mon Sep 17 00:00:00 2001 From: Jonas Wunderlich Date: Thu, 31 Aug 2023 14:21:34 +0200 Subject: [PATCH 1/2] fix None timeout issues --- pyodide_http/_requests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyodide_http/_requests.py b/pyodide_http/_requests.py index 5542d6c..6329433 100644 --- a/pyodide_http/_requests.py +++ b/pyodide_http/_requests.py @@ -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) > 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 From 5f9ce716c03159ffb65b2257b948eb2bc13fde64 Mon Sep 17 00:00:00 2001 From: Jonas Wunderlich Date: Mon, 4 Sep 2023 19:00:42 +0200 Subject: [PATCH 2/2] fix: checked wrong length --- pyodide_http/_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyodide_http/_requests.py b/pyodide_http/_requests.py index 6329433..a3980cc 100644 --- a/pyodide_http/_requests.py +++ b/pyodide_http/_requests.py @@ -37,7 +37,7 @@ def send(self, request, **kwargs): pyodide_request.timeout = (pyodide_request.timeout[0] or 0) + ( pyodide_request.timeout[1] or 0 ) - elif len(pyodide_request) > 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