Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
f19b0c68
Commit
f19b0c68
authored
Feb 21, 2019
by
juga
Browse files
requests: Add class to override Session methods
Override get and head methods to always have a timeout.
parent
b9bc234e
Changes
1
Hide whitespace changes
Inline
Side-by-side
sbws/util/requests.py
View file @
f19b0c68
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment