Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-core
Commits
eec4699f
Verified
Commit
eec4699f
authored
6 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
swh.core.api.SWHRemoteAPI: Permit to set a timeout option
Related T1061
parent
89f329d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/core/api.py
+6
-1
6 additions, 1 deletion
swh/core/api.py
with
6 additions
and
1 deletion
swh/core/api.py
+
6
−
1
View file @
eec4699f
...
...
@@ -24,17 +24,20 @@ class SWHRemoteAPI:
"""
def
__init__
(
self
,
api_exception
,
url
):
def
__init__
(
self
,
api_exception
,
url
,
timeout
=
None
):
super
().
__init__
()
self
.
api_exception
=
api_exception
base_url
=
url
if
url
.
endswith
(
'
/
'
)
else
url
+
'
/
'
self
.
url
=
base_url
self
.
session
=
requests
.
Session
()
self
.
timeout
=
timeout
def
_url
(
self
,
endpoint
):
return
'
%s%s
'
%
(
self
.
url
,
endpoint
)
def
raw_post
(
self
,
endpoint
,
data
,
**
opts
):
if
self
.
timeout
and
'
timeout
'
not
in
opts
:
opts
[
'
timeout
'
]
=
self
.
timeout
try
:
return
self
.
session
.
post
(
self
.
_url
(
endpoint
),
...
...
@@ -45,6 +48,8 @@ class SWHRemoteAPI:
raise
self
.
api_exception
(
e
)
def
raw_get
(
self
,
endpoint
,
params
=
None
,
**
opts
):
if
self
.
timeout
and
'
timeout
'
not
in
opts
:
opts
[
'
timeout
'
]
=
self
.
timeout
try
:
return
self
.
session
.
get
(
self
.
_url
(
endpoint
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment