init
This commit is contained in:
14
adapter.py
Normal file
14
adapter.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
||||
class WhyTheFuckRequestsHasNoTimeoutInAdapter(HTTPAdapter):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "timeout" in kwargs:
|
||||
self.timeout = kwargs["timeout"]
|
||||
del kwargs["timeout"]
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def send(self, request, **kwargs):
|
||||
timeout = kwargs.get("timeout")
|
||||
if timeout is None and hasattr(self, 'timeout'):
|
||||
kwargs["timeout"] = self.timeout
|
||||
return super().send(request, **kwargs)
|
Reference in New Issue
Block a user