Skip to content

Instantly share code, notes, and snippets.

@Cologler
Last active August 21, 2022 03:58
Show Gist options
  • Save Cologler/6d64555f801f4631a96c9efad61358f8 to your computer and use it in GitHub Desktop.
Save Cologler/6d64555f801f4631a96c9efad61358f8 to your computer and use it in GitHub Desktop.
# copied from https://stackoverflow.com/questions/17782142/
def patch_requests_timeout(default_timeout: float) -> None:
import requests
old_send = requests.Session.send
def new_send(*args, **kwargs):
if kwargs.get("timeout", None) is None:
kwargs["timeout"] = default_timeout
return old_send(*args, **kwargs)
requests.Session.send = new_send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment