Skip to content

Commit e56cf1d

Browse files
authored
Added scheduler flag. (#143)
Closes #142.
1 parent 28692eb commit e56cf1d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

taskiq/abc/broker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ class AsyncBroker(ABC):
6868
"""
6969

7070
available_tasks: Dict[str, AsyncTaskiqDecoratedTask[Any, Any]] = {}
71+
# True only if broker runs in worker process.
7172
is_worker_process: bool = False
73+
# True only if broker runs in scheduler process.
74+
is_scheduler_process: bool = False
7275

7376
def __init__(
7477
self,

taskiq/cli/scheduler/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from pycron import is_now
77

8+
from taskiq.abc.broker import AsyncBroker
89
from taskiq.cli.scheduler.args import SchedulerArgs
910
from taskiq.cli.utils import import_object, import_tasks
1011
from taskiq.kicker import AsyncKicker
@@ -70,6 +71,7 @@ async def run_scheduler(args: SchedulerArgs) -> None: # noqa: C901, WPS210, WPS
7071
7172
:param args: parsed CLI args.
7273
"""
74+
AsyncBroker.is_scheduler_process = True
7375
scheduler = import_object(args.scheduler)
7476
if not isinstance(scheduler, TaskiqScheduler):
7577
print( # noqa: WPS421

0 commit comments

Comments
 (0)