Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flamenco-worker-python
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
Container Registry
Model registry
Operate
Environments
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
blender
flamenco-worker-python
Commits
20b9cf28
Commit
20b9cf28
authored
8 years ago
by
Sybren A. Stüvel
Browse files
Options
Downloads
Patches
Plain Diff
Worker: push updates to manager before shutting down
parent
c813ed28
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
packages/flamenco-worker-python/flamenco_worker/worker.py
+13
-1
13 additions, 1 deletion
packages/flamenco-worker-python/flamenco_worker/worker.py
with
13 additions
and
1 deletion
packages/flamenco-worker-python/flamenco_worker/worker.py
+
13
−
1
View file @
20b9cf28
...
...
@@ -164,6 +164,15 @@ class FlamencoWorker:
def
shutdown
(
self
):
"""
Gracefully shuts down any asynchronous tasks.
"""
push_act_sched
=
self
.
_push_act_to_manager
is
not
None
\
and
not
self
.
_push_act_to_manager
.
done
()
push_log_sched
=
self
.
_push_log_to_manager
is
not
None
\
and
not
self
.
_push_log_to_manager
.
done
()
if
push_act_sched
or
push_log_sched
:
# Try to push queued task updates to master before shutting down
self
.
_log
.
info
(
'
shutdown(): pushing queued updates to manager
'
)
self
.
loop
.
run_until_complete
(
self
.
push_to_manager
())
if
self
.
fetch_task_task
is
None
or
self
.
fetch_task_task
.
done
():
return
...
...
@@ -244,7 +253,7 @@ class FlamencoWorker:
# when we're in some infinite failure loop.
self
.
schedule_fetch_task
(
FETCH_TASK_DONE_SCHEDULE_NEW_DELAY
)
async
def
push_to_manager
(
self
,
*
,
delay
:
datetime
.
timedelta
=
None
):
async
def
push_to_manager
(
self
,
*
,
delay
:
datetime
.
timedelta
=
None
):
"""
Updates a task
'
s status and activity.
Uses the TaskUpdateQueue to handle persistent queueing.
...
...
@@ -255,6 +264,9 @@ class FlamencoWorker:
self
.
_log
.
debug
(
'
Scheduled delayed push to master in %r seconds
'
,
delay_sec
)
await
asyncio
.
sleep
(
delay_sec
)
if
self
.
shutdown_future
.
done
():
self
.
_log
.
info
(
'
Shutting down, not pushing changes to master.
'
)
self
.
_log
.
info
(
'
Updating task %s with status %r and activity %r
'
,
self
.
task_id
,
self
.
current_task_status
,
self
.
last_task_activity
)
...
...
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