Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Workers
Base Worker
Commits
d1992513
Commit
d1992513
authored
3 years ago
by
Valentin Rigal
Committed by
Bastien Abadie
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle concurrency while initializing activity
parent
6b9540d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex_worker/worker/__init__.py
+13
-1
13 additions, 1 deletion
arkindex_worker/worker/__init__.py
with
13 additions
and
1 deletion
arkindex_worker/worker/__init__.py
+
13
−
1
View file @
d1992513
...
...
@@ -127,7 +127,18 @@ class ElementsWorker(
logger
.
info
(
f
"
Processing
{
element
}
(
{
i
}
/
{
count
}
)
"
)
# Process the element and report its progress if activities are enabled
self
.
update_activity
(
element
.
id
,
ActivityState
.
Started
)
response
=
self
.
update_activity
(
element
.
id
,
ActivityState
.
Started
)
if
isinstance
(
response
,
ErrorResponse
)
and
response
.
status_code
==
400
:
# Bad request error when setting an activity to "started" mean that we cannot
# process this element. We assume that the reason is that the state transition
# was forbidden i.e. that the activity was already in a started or processed state.
# This allow concurrent access to an element activity.
# Element is not counted as failed as it is handled by another process.
logger
.
info
(
f
'
Cannot start processing element
"
{
element
.
id
}
"
.
'
"
Another process could have processed it with the same version already.
"
)
continue
self
.
process_element
(
element
)
self
.
update_activity
(
element
.
id
,
ActivityState
.
Processed
)
except
Exception
as
e
:
...
...
@@ -201,6 +212,7 @@ class ElementsWorker(
logger
.
warning
(
f
"
Failed to update activity of element
{
element_id
}
to
{
state
.
value
}
due to an API error:
{
e
.
content
}
"
)
return
e
except
Exception
as
e
:
logger
.
warning
(
f
"
Failed to update activity of element
{
element_id
}
to
{
state
.
value
}
:
{
e
}
"
...
...
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