Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toargridding
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
Container 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
esde
toar-public
toargridding
Commits
849fc4df
Commit
849fc4df
authored
11 months ago
by
Carsten Hinz
Browse files
Options
Downloads
Patches
Plain Diff
added waiting time before restarting a request
parent
7cce3ae8
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Creation of first beta release version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toargridding/toar_rest_client.py
+5
-3
5 additions, 3 deletions
toargridding/toar_rest_client.py
with
5 additions
and
3 deletions
toargridding/toar_rest_client.py
+
5
−
3
View file @
849fc4df
...
@@ -257,7 +257,8 @@ class Connection:
...
@@ -257,7 +257,8 @@ class Connection:
This function catches possible connection issues and continues to
This function catches possible connection issues and continues to
"""
"""
status_endpoint
=
self
.
get_status_endpoint
(
query_options
)
status_endpoint
=
self
.
get_status_endpoint
(
query_options
)
nRestart
=
0
waitRestart
=
300
for
i
,
wait_time
in
enumerate
(
self
.
wait_seconds
):
for
i
,
wait_time
in
enumerate
(
self
.
wait_seconds
):
logger
.
info
(
f
"
try:
{
i
+
1
}
, wait_time:
{
wait_time
}
"
)
logger
.
info
(
f
"
try:
{
i
+
1
}
, wait_time:
{
wait_time
}
"
)
response
=
self
.
wait_and_get
(
status_endpoint
,
wait_secs
=
wait_time
)
response
=
self
.
wait_and_get
(
status_endpoint
,
wait_secs
=
wait_time
)
...
@@ -269,7 +270,8 @@ class Connection:
...
@@ -269,7 +270,8 @@ class Connection:
self
.
printExecption
(
e
,
response
)
self
.
printExecption
(
e
,
response
)
#a Status Code 500 seems indicated an aborted request -> restart the request and continue with new status endpoint
#a Status Code 500 seems indicated an aborted request -> restart the request and continue with new status endpoint
if
e
.
response
.
status_code
==
500
:
if
e
.
response
.
status_code
==
500
:
logger
.
warning
(
"
Received internal server error. Restarting request.
"
)
logger
.
warning
(
f
"
Received internal server error. Restarting request in
{
waitRestart
}
s.
"
)
time
.
sleep
(
waitRestart
)
self
.
cache
.
remove
(
query_options
.
cache_key
)
self
.
cache
.
remove
(
query_options
.
cache_key
)
status_endpoint
=
self
.
get_status_endpoint
(
query_options
)
status_endpoint
=
self
.
get_status_endpoint
(
query_options
)
else
:
else
:
...
@@ -281,7 +283,7 @@ class Connection:
...
@@ -281,7 +283,7 @@ class Connection:
return
response
return
response
else
:
else
:
raise
RuntimeError
(
raise
RuntimeError
(
f
"
No data available after
{
sum
(
self
.
wait_seconds
)
/
60
}
minutes. retry later.
"
f
"
No data available after
{
sum
(
self
.
wait_seconds
)
/
60
+
nRestart
*
waitRestart
/
60
}
minutes. retry later.
"
)
)
def
get_status_endpoint
(
self
,
query_options
:
QueryOptions
)
->
str
:
def
get_status_endpoint
(
self
,
query_options
:
QueryOptions
)
->
str
:
...
...
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