Skip to content

Commit acfcc65

Browse files
committed
Change name to durable_task
1 parent b1e6a51 commit acfcc65

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

ansible_base/task/publish.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def delay(self, *args, **kwargs):
2727

2828
class TaskDecorator:
2929
def __init__(self, *args, **kwargs):
30+
# TODO: this will process a task timeout, just not yet set up
3031
self.args = args
3132
self.kwargs = kwargs
3233

@@ -39,5 +40,5 @@ def __call__(self, fn):
3940
return fn
4041

4142

42-
def task():
43+
def durable_task():
4344
return TaskDecorator()

ansible_base/task/tasks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ def run_task_from_queue():
2929
logger.traceback(f'Failed to run and complete {task.name}')
3030

3131
task.delete()
32+
33+
34+
# TODO: Add a "reaper" fallback task, this is currently blocked on dispatcher issue
35+
# https://github.com/ansible/dispatcher/issues/6
36+
# When run_task_from_queue starts the task, the uuid needs to be setup to be discoverable
37+
# this fallback method will query for tasks that are older than a certain grace period
38+
# later improvement: look for tasks older that the task timeout plus a grace period
39+
# these tasks are in arrears
40+
# For each task in arrears, we will:
41+
# 1. obtain a row-level lock for that task
42+
# 2. send a roll-call message looking for its uuid
43+
# 3. if we get no answer to the roll-call, the task status is changed to lost
44+
# 4. dependent on policies defined in settings, we may re-submit the task up to a retry count
45+
# 5. if retry count is exhausted, task is failed

test_app/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import time
22

3-
from ansible_base.task.publish import task
3+
from ansible_base.task.publish import durable_tasktask
44

55

6-
@task()
6+
@durable_tasktask()
77
def hello_world():
88
print('hello world')
99

1010

11-
@task()
11+
@durable_tasktask()
1212
def sleep(seconds=2):
1313
print(f'about to sleep for {seconds} seconds')
1414
time.sleep(seconds)

0 commit comments

Comments
 (0)