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
nomad-lab
nomad-FAIR
Commits
61141ead
Commit
61141ead
authored
Mar 06, 2019
by
Markus Scheidgen
Browse files
Thread safe bravado usage.
parent
c310fb26
Changes
1
Hide whitespace changes
Inline
Side-by-side
nomad/migration.py
View file @
61141ead
...
...
@@ -647,10 +647,13 @@ class NomadCOEMigration:
return
overall_report
_client_lock
=
threading
.
Lock
()
def
nomad
(
self
,
operation
:
str
,
*
args
,
**
kwargs
)
->
Any
:
"""
Calls nomad via the bravado client. It deals with a very busy nomad and catches,
backsoff, and retries on gateway timouts.
backsoff, and retries on gateway timouts. It also circumvents bravados/jsonschemas
thread safety issues using a global lock on client usage.
Arguments:
operation: Comma separated string of api, endpoint, operation,
...
...
@@ -662,22 +665,16 @@ class NomadCOEMigration:
op
=
getattr
(
op
,
op_path_segment
)
sleep
=
utils
.
SleepTimeBackoff
()
retries_after_error
=
0
while
True
:
try
:
NomadCOEMigration
.
_client_lock
.
acquire
(
blocking
=
True
)
return
op
(
*
args
,
**
kwargs
).
response
().
result
except
HTTPGatewayTimeout
:
sleep
()
except
IndexError
as
e
:
# this happens sometime in bravados swagger marshalling, lets also retry
# a couple of times
if
retries_after_error
<
3
:
retries_after_error
+=
1
sleep
()
else
:
raise
e
except
Exception
as
e
:
raise
e
finally
:
NomadCOEMigration
.
_client_lock
.
release
()
def
migrate_package
(
self
,
package
:
Package
,
local
:
bool
=
False
):
source_upload_id
=
package
.
upload_id
...
...
Write
Preview
Supports
Markdown
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