Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docs/_build
htmlcov
VERSION.txt
.benchmarks
.python-version
12 changes: 7 additions & 5 deletions procrastinate/types.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from __future__ import annotations

import datetime
import typing as t
from typing import NamedTuple, TypedDict

from typing_extensions import NotRequired
from typing_extensions import NotRequired, TypeAlias

JSONValue = t.Union[str, int, float, bool, None, dict[str, t.Any], list[t.Any]]
JSONValue: TypeAlias = (
'dict[str, "JSONValue"] | list["JSONValue"] | str | int | float | bool | None'
)
JSONDict = dict[str, JSONValue]


class TimeDeltaParams(t.TypedDict):
class TimeDeltaParams(TypedDict):
weeks: NotRequired[int]
days: NotRequired[int]
hours: NotRequired[int]
Expand All @@ -19,7 +21,7 @@ class TimeDeltaParams(t.TypedDict):
microseconds: NotRequired[int]


class JobToDefer(t.NamedTuple):
class JobToDefer(NamedTuple):
queue_name: str
task_name: str
priority: int
Expand Down
13 changes: 7 additions & 6 deletions procrastinate/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ def _log_extra(
job_result: job_context.JobResult | None,
**kwargs: Any,
) -> types.JSONDict:
worker: types.JSONDict = {
"name": self.worker_name,
"worker_id": self.worker_id,
"job_id": context.job.id if context else None,
"queues": list(self.queues or []),
}
extra: types.JSONDict = {
"action": action,
"worker": {
"name": self.worker_name,
"worker_id": self.worker_id,
"job_id": context.job.id if context else None,
"queues": self.queues,
},
"worker": worker,
}
if context:
extra["job"] = context.job.log_context()
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import datetime
import functools

Expand Down Expand Up @@ -315,6 +316,7 @@ async def test_get_stalled_jobs_by_heartbeat__pruned_worker(

async def test_register_and_unregister_worker(pg_job_manager, psycopg_connector):
then = utils.utcnow()
await asyncio.sleep(0)
worker_id = await pg_job_manager.register_worker()
assert worker_id is not None

Expand Down