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
1cc8351c
Commit
1cc8351c
authored
Feb 21, 2019
by
juga
Browse files
requests: Change make_session to use the TimedSession
that will always have timeout in the get and head methods.
parent
f19b0c68
Changes
1
Hide whitespace changes
Inline
Side-by-side
sbws/util/requests.py
View file @
1cc8351c
...
...
@@ -18,12 +18,17 @@ class TimedSession(requests.Session):
def
make_session
(
controller
,
timeout
):
s
=
requests
.
Session
()
"""
Initialize a TimedSession with the timeout, the proxies and the headers.
"""
s
=
TimedSession
()
socks_info
=
stem_utils
.
get_socks_info
(
controller
)
s
.
proxies
=
{
'http'
:
'socks5h://{}:{}'
.
format
(
*
socks_info
),
'https'
:
'socks5h://{}:{}'
.
format
(
*
socks_info
),
}
s
.
timeout
=
timeout
# ``_timeout`` is not used by request's Session, but it is by TimedSession.
s
.
_timeout
=
timeout
s
.
headers
=
settings
.
HTTP_HEADERS
return
s
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