pydocket 0.9.2__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pydocket might be problematic. Click here for more details.
- docket/execution.py +3 -0
- docket/instrumentation.py +6 -0
- docket/worker.py +14 -3
- {pydocket-0.9.2.dist-info → pydocket-0.11.0.dist-info}/METADATA +1 -1
- pydocket-0.11.0.dist-info/RECORD +16 -0
- pydocket-0.9.2.dist-info/RECORD +0 -16
- {pydocket-0.9.2.dist-info → pydocket-0.11.0.dist-info}/WHEEL +0 -0
- {pydocket-0.9.2.dist-info → pydocket-0.11.0.dist-info}/entry_points.txt +0 -0
- {pydocket-0.9.2.dist-info → pydocket-0.11.0.dist-info}/licenses/LICENSE +0 -0
docket/execution.py
CHANGED
|
@@ -51,6 +51,7 @@ class Execution:
|
|
|
51
51
|
key: str,
|
|
52
52
|
attempt: int,
|
|
53
53
|
trace_context: opentelemetry.context.Context | None = None,
|
|
54
|
+
redelivered: bool = False,
|
|
54
55
|
) -> None:
|
|
55
56
|
self.function = function
|
|
56
57
|
self.args = args
|
|
@@ -59,6 +60,7 @@ class Execution:
|
|
|
59
60
|
self.key = key
|
|
60
61
|
self.attempt = attempt
|
|
61
62
|
self.trace_context = trace_context
|
|
63
|
+
self.redelivered = redelivered
|
|
62
64
|
|
|
63
65
|
def as_message(self) -> Message:
|
|
64
66
|
return {
|
|
@@ -80,6 +82,7 @@ class Execution:
|
|
|
80
82
|
key=message[b"key"].decode(),
|
|
81
83
|
attempt=int(message[b"attempt"].decode()),
|
|
82
84
|
trace_context=propagate.extract(message, getter=message_getter),
|
|
85
|
+
redelivered=False, # Default to False, will be set to True in worker if it's a redelivery
|
|
83
86
|
)
|
|
84
87
|
|
|
85
88
|
def general_labels(self) -> Mapping[str, str]:
|
docket/instrumentation.py
CHANGED
|
@@ -40,6 +40,12 @@ TASKS_STARTED = meter.create_counter(
|
|
|
40
40
|
unit="1",
|
|
41
41
|
)
|
|
42
42
|
|
|
43
|
+
TASKS_REDELIVERED = meter.create_counter(
|
|
44
|
+
"docket_tasks_redelivered",
|
|
45
|
+
description="How many tasks started that were redelivered from another worker",
|
|
46
|
+
unit="1",
|
|
47
|
+
)
|
|
48
|
+
|
|
43
49
|
TASKS_STRICKEN = meter.create_counter(
|
|
44
50
|
"docket_tasks_stricken",
|
|
45
51
|
description="How many tasks have been stricken from executing",
|
docket/worker.py
CHANGED
|
@@ -47,6 +47,7 @@ from .instrumentation import (
|
|
|
47
47
|
TASKS_COMPLETED,
|
|
48
48
|
TASKS_FAILED,
|
|
49
49
|
TASKS_PERPETUATED,
|
|
50
|
+
TASKS_REDELIVERED,
|
|
50
51
|
TASKS_RETRIED,
|
|
51
52
|
TASKS_RUNNING,
|
|
52
53
|
TASKS_STARTED,
|
|
@@ -286,7 +287,11 @@ class Worker:
|
|
|
286
287
|
count=available_slots,
|
|
287
288
|
)
|
|
288
289
|
|
|
289
|
-
def start_task(
|
|
290
|
+
def start_task(
|
|
291
|
+
message_id: RedisMessageID,
|
|
292
|
+
message: RedisMessage,
|
|
293
|
+
is_redelivery: bool = False,
|
|
294
|
+
) -> bool:
|
|
290
295
|
function_name = message[b"function"].decode()
|
|
291
296
|
if not (function := self.docket.tasks.get(function_name)):
|
|
292
297
|
logger.warning(
|
|
@@ -297,6 +302,7 @@ class Worker:
|
|
|
297
302
|
return False
|
|
298
303
|
|
|
299
304
|
execution = Execution.from_message(function, message)
|
|
305
|
+
execution.redelivered = is_redelivery
|
|
300
306
|
|
|
301
307
|
task = asyncio.create_task(self._execute(execution), name=execution.key)
|
|
302
308
|
active_tasks[task] = message_id
|
|
@@ -342,12 +348,15 @@ class Worker:
|
|
|
342
348
|
continue
|
|
343
349
|
|
|
344
350
|
for source in [get_redeliveries, get_new_deliveries]:
|
|
345
|
-
for
|
|
351
|
+
for stream_key, messages in await source(redis):
|
|
352
|
+
is_redelivery = stream_key == b"__redelivery__"
|
|
346
353
|
for message_id, message in messages:
|
|
347
354
|
if not message: # pragma: no cover
|
|
348
355
|
continue
|
|
349
356
|
|
|
350
|
-
task_started = start_task(
|
|
357
|
+
task_started = start_task(
|
|
358
|
+
message_id, message, is_redelivery
|
|
359
|
+
)
|
|
351
360
|
if not task_started:
|
|
352
361
|
# Other errors - delete and ack
|
|
353
362
|
await self._delete_known_task(redis, message)
|
|
@@ -521,6 +530,8 @@ class Worker:
|
|
|
521
530
|
duration = 0.0
|
|
522
531
|
|
|
523
532
|
TASKS_STARTED.add(1, counter_labels)
|
|
533
|
+
if execution.redelivered:
|
|
534
|
+
TASKS_REDELIVERED.add(1, counter_labels)
|
|
524
535
|
TASKS_RUNNING.add(1, counter_labels)
|
|
525
536
|
TASK_PUNCTUALITY.record(punctuality, counter_labels)
|
|
526
537
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydocket
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: A distributed background task system for Python functions
|
|
5
5
|
Project-URL: Homepage, https://github.com/chrisguidry/docket
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/chrisguidry/docket/issues
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
docket/__init__.py,sha256=onwZzh73tESWoFBukbcW-7gjxoXb-yI7dutRD7tPN6g,915
|
|
2
|
+
docket/__main__.py,sha256=wcCrL4PjG51r5wVKqJhcoJPTLfHW0wNbD31DrUN0MWI,28
|
|
3
|
+
docket/annotations.py,sha256=wttix9UOeMFMAWXAIJUfUw5GjESJZsACb4YXJCozP7Q,2348
|
|
4
|
+
docket/cli.py,sha256=rTfri2--u4Q5PlXyh7Ub_F5uh3-TtZOWLUp9WY_TvAE,25750
|
|
5
|
+
docket/dependencies.py,sha256=BC0bnt10cr9_S1p5JAP_bnC9RwZkTr9ulPBrxC7eZnA,20247
|
|
6
|
+
docket/docket.py,sha256=jP5uI02in5chQvovRsnPaMhgLff3uiK42A-l3eBh2sE,31241
|
|
7
|
+
docket/execution.py,sha256=Lqzgj5EO3v5OD0w__5qBut7WnlEcHZfAYj-BYRdiJf8,15138
|
|
8
|
+
docket/instrumentation.py,sha256=zLYgtuXbNOcotcSlD9pgLVdNp2rPddyxj9JwM3K19Go,5667
|
|
9
|
+
docket/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
docket/tasks.py,sha256=RIlSM2omh-YDwVnCz6M5MtmK8T_m_s1w2OlRRxDUs6A,1437
|
|
11
|
+
docket/worker.py,sha256=hv9ug5WIVAEFPUBCbJ5-lobInwNdMfi7-Ja6fLKdEQ8,35392
|
|
12
|
+
pydocket-0.11.0.dist-info/METADATA,sha256=e34sVFSTXKuWhQ0O60UHfzkGojfAiEMNMkG9pjLGEqo,5419
|
|
13
|
+
pydocket-0.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
pydocket-0.11.0.dist-info/entry_points.txt,sha256=4WOk1nUlBsUT5O3RyMci2ImuC5XFswuopElYcLHtD5k,47
|
|
15
|
+
pydocket-0.11.0.dist-info/licenses/LICENSE,sha256=YuVWU_ZXO0K_k2FG8xWKe5RGxV24AhJKTvQmKfqXuyk,1087
|
|
16
|
+
pydocket-0.11.0.dist-info/RECORD,,
|
pydocket-0.9.2.dist-info/RECORD
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
docket/__init__.py,sha256=onwZzh73tESWoFBukbcW-7gjxoXb-yI7dutRD7tPN6g,915
|
|
2
|
-
docket/__main__.py,sha256=wcCrL4PjG51r5wVKqJhcoJPTLfHW0wNbD31DrUN0MWI,28
|
|
3
|
-
docket/annotations.py,sha256=wttix9UOeMFMAWXAIJUfUw5GjESJZsACb4YXJCozP7Q,2348
|
|
4
|
-
docket/cli.py,sha256=rTfri2--u4Q5PlXyh7Ub_F5uh3-TtZOWLUp9WY_TvAE,25750
|
|
5
|
-
docket/dependencies.py,sha256=BC0bnt10cr9_S1p5JAP_bnC9RwZkTr9ulPBrxC7eZnA,20247
|
|
6
|
-
docket/docket.py,sha256=jP5uI02in5chQvovRsnPaMhgLff3uiK42A-l3eBh2sE,31241
|
|
7
|
-
docket/execution.py,sha256=r_2RGC1qhtAcBUg7E6wewLEgftrf3hIxNbH0HnYPbek,14961
|
|
8
|
-
docket/instrumentation.py,sha256=ogvzrfKbWsdPGfdg4hByH3_r5d3b5AwwQkSrmXw0hRg,5492
|
|
9
|
-
docket/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
docket/tasks.py,sha256=RIlSM2omh-YDwVnCz6M5MtmK8T_m_s1w2OlRRxDUs6A,1437
|
|
11
|
-
docket/worker.py,sha256=S5HG87vHa_r1JKApHpEtNkVdUhkdi802zUw3h_zIHt0,34998
|
|
12
|
-
pydocket-0.9.2.dist-info/METADATA,sha256=gWX-2gIAQ5pn3fQ1XwFweQYnbXwsgIpGVahW7KJJNtU,5418
|
|
13
|
-
pydocket-0.9.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
-
pydocket-0.9.2.dist-info/entry_points.txt,sha256=4WOk1nUlBsUT5O3RyMci2ImuC5XFswuopElYcLHtD5k,47
|
|
15
|
-
pydocket-0.9.2.dist-info/licenses/LICENSE,sha256=YuVWU_ZXO0K_k2FG8xWKe5RGxV24AhJKTvQmKfqXuyk,1087
|
|
16
|
-
pydocket-0.9.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|