Commit f19b0c68 authored by juga's avatar juga
Browse files

requests: Add class to override Session methods

Override get and head methods to always have a timeout.
parent b9bc234e
import requests
from sbws import settings
import sbws.util.stem as stem_utils
from sbws.util import stem as stem_utils
class TimedSession(requests.Session):
"""Requests Session that sends timeout in the head and get methods.
"""
def get(self, url, **kwargs):
return super().get(url, timeout=getattr(self, "_timeout", None),
**kwargs)
def head(self, url, **kwargs):
return super().head(url, timeout=getattr(self, "_timeout", None),
**kwargs)
def make_session(controller, timeout):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment