Skip to content

Commit 9c32220

Browse files
committed
Run linters
1 parent de7ad1b commit 9c32220

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

ansible_base/task/management/commands/run_dispatcher.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dispatcher.main import DispatcherMain
2-
32
from django.core.management.base import BaseCommand
43

54

@@ -12,9 +11,7 @@ def handle(self, *args, **options):
1211
"brokers": {
1312
"pg_notify": {"conninfo": settings.PG_NOTIFY_DSN_SERVER},
1413
# TODO: sanitize or escape channel names on dispatcher side
15-
"channels": [
16-
"dab_broadcast"
17-
],
14+
"channels": ["dab_broadcast"],
1815
},
1916
# NOTE: I would prefer to move the activation monitoring
2017
# from worker to activation, but that is more work
@@ -23,4 +20,4 @@ def handle(self, *args, **options):
2320
"pool": {"max_workers": 4},
2421
}
2522

26-
DispatcherMain()
23+
DispatcherMain()

ansible_base/task/models.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from uuid import uuid4
21
from types import SimpleNamespace
2+
from uuid import uuid4
33

44
from django.db import models
5-
from django.utils.translation import gettext_lazy as _
65
from django.utils.timezone import now
6+
from django.utils.translation import gettext_lazy as _
77

88
# NOTE: tasks are not registered in the database, but in a dispatcher registry
99

@@ -23,32 +23,21 @@ class Task(models.Model):
2323
Corresponds to a call of a task, as a higher-level abstraction around the dispatcher.
2424
Loosely modeled after pulpcore.Task
2525
"""
26-
uuid = models.UUIDField(
27-
primary_key=True, default=uuid4, editable=False,
28-
help_text=_('UUID that corresponds to the dispatcher task uuid')
29-
)
26+
27+
uuid = models.UUIDField(primary_key=True, default=uuid4, editable=False, help_text=_('UUID that corresponds to the dispatcher task uuid'))
3028
state = models.CharField(
3129
choices=[(s, s.title()) for s in sorted(vars(TASK_STATES).values())],
3230
default=TASK_STATES.WAITING,
33-
help_text=_('Choices of this field track with acknowledgement and completion of a task')
34-
)
35-
name = models.TextField(
36-
help_text=_('Importable path for class or method')
31+
help_text=_('Choices of this field track with acknowledgement and completion of a task'),
3732
)
33+
name = models.TextField(help_text=_('Importable path for class or method'))
3834

3935
created = models.DateTimeField(
40-
auto_now_add=True,
41-
help_text=_('Time the publisher (submitter) of this task call created it, approximately the time of submission as well')
36+
auto_now_add=True, help_text=_('Time the publisher (submitter) of this task call created it, approximately the time of submission as well')
4237
)
4338
# pulp has unblocking logic, like unblocked_at, we have no plans for that here
44-
started_at = models.DateTimeField(
45-
null=True,
46-
help_text=_('Time of acknowledgement, also approximately the time the task starts')
47-
)
48-
finished_at = models.DateTimeField(
49-
null=True,
50-
help_text=_('Time task is cleared (whether failed or succeeded), may be unused if set to auto-delete')
51-
)
39+
started_at = models.DateTimeField(null=True, help_text=_('Time of acknowledgement, also approximately the time the task starts'))
40+
finished_at = models.DateTimeField(null=True, help_text=_('Time task is cleared (whether failed or succeeded), may be unused if set to auto-delete'))
5241

5342
def mark_ack(self):
5443
self.state = TASK_STATES.RUNNING

ansible_base/task/publish.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from django.db import transaction
2-
31
from dispatcher.utils import serialize_task
2+
from django.db import transaction
43

5-
from ansible_base.task.tasks import run_task_from_queue
64
from ansible_base.task.models import Task
5+
from ansible_base.task.tasks import run_task_from_queue
76

87
# decorator structure is taken from dispatcher.publish
98

9+
1010
class TaskPublisher:
1111
def __init__(self, fn):
1212
self.fn = fn

ansible_base/task/tasks.py

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

3-
from ansible_base.task.models import Task, TASK_STATES
4-
53
from dispatcher.utils import resolve_callable
6-
74
from django.db import transaction
85

6+
from ansible_base.task.models import TASK_STATES, Task
7+
98
logger = logging.getLogger(__name__)
109

1110

0 commit comments

Comments
 (0)