15 lines
526 B
Python
15 lines
526 B
Python
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)
|