Skip to content

Commit

Permalink
Merge pull request #61 from madeddie/Add-global-timeout
Browse files Browse the repository at this point in the history
Add global http timeout to the session
  • Loading branch information
madeddie committed May 28, 2024
2 parents 87451bf + f30cc3a commit f319495
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tyora/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from .utils import find_link, parse_form

HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10))
logger = logging.getLogger(__name__)

try:
Expand All @@ -33,6 +34,10 @@ def __init__(
{"User-Agent": user_agent(os.path.basename(sys.argv[0]), __version__)}
)

def request(self, *args, **kwargs):
kwargs.setdefault("timeout", HTTP_TIMEOUT)
return super(MoocfiCsesSession, self).request(*args, **kwargs)

@property
def is_logged_in(self) -> bool:
res = self.get(urljoin(self.base_url, "list"))
Expand Down

0 comments on commit f319495

Please sign in to comment.