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
6 changes: 6 additions & 0 deletions crates/fluxqueue-worker/scripts/get_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ def get_registry( # noqa: C901
registry = {"tasks": {}, "contexts": {}}
for _name, obj in inspect.getmembers(module):
if inspect.isfunction(obj):
is_fluxqueue_task = getattr(obj, "fluxqueue", False)

if not is_fluxqueue_task:
continue

task_name = getattr(obj, "task_name", None)
task_queue = getattr(obj, "queue", None)

if not task_queue or task_queue != queue:
continue

Expand Down
10 changes: 7 additions & 3 deletions python/fluxqueue/_task.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations

import inspect
from collections.abc import Callable, Coroutine
from functools import wraps
from typing import Any, ParamSpec, cast, get_type_hints, overload
from typing import TYPE_CHECKING, Any, ParamSpec, cast, get_type_hints, overload

from ._core import FluxQueueCore
from .utils import get_task_name

if TYPE_CHECKING:
from ._core import FluxQueueCore

P = ParamSpec("P")


Expand Down Expand Up @@ -47,7 +51,7 @@ def _task_decorator(

task_name = get_task_name(func, name)

# TODO: Add unique identifier 'fluxqueue' just to be 100% sure
cast(Any, func).fluxqueue = True
cast(Any, func).task_name = task_name
cast(Any, func).queue = queue

Expand Down
19 changes: 16 additions & 3 deletions python/fluxqueue/context.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
from __future__ import annotations

import inspect
import threading
from collections.abc import Callable, Coroutine
from contextvars import ContextVar
from typing import Any, Concatenate, ParamSpec, TypeVar, cast, get_type_hints, overload
from typing import (
TYPE_CHECKING,
Any,
Concatenate,
ParamSpec,
TypeVar,
cast,
get_type_hints,
overload,
)

from ._core import FluxQueueCore
from ._task import _task_decorator
from .models import TaskMetadata

if TYPE_CHECKING:
from ._core import FluxQueueCore
from .models import TaskMetadata

P = ParamSpec("P")

Expand Down