Skip to content

Conversation

@dtatarkin
Copy link
Contributor

… when parsing from the command line using the WorkerArgs.from_cli() method.

This may be useful if you want to implement a custom command-line interface (CLI) command to run project-specific workers with custom default arguments.

Here is how I use Taskiq with Django:

import logging import os from collections.abc import Sequence import configurations from taskiq.abc.cmd import TaskiqCMD from taskiq.cli.worker.args import WorkerArgs from taskiq.cli.worker.run import run_worker logger = logging.getLogger(__name__) class ProjectWorkerCMD(TaskiqCMD): short_help = "Run Taskiq worker" def exec(self, args: Sequence[str]) -> None: os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings.web") os.environ.setdefault("DJANGO_CONFIGURATION", "Web") configurations.setup() worker_args = WorkerArgs.from_cli(args, defaults=dict( fs_discover=True, app_dir="src/project/root/", tasks_pattern=['**/taskiq/tasks.py'], )) run_worker(args=worker_args) 
… the command line using the WorkerArgs.from_cli() method.
@s3rius
Copy link
Member

s3rius commented Nov 30, 2025

Can you please fix conflicts?

@danfimov
Copy link
Member

danfimov commented Dec 1, 2025

@s3rius conflict fixed. Do you need any other changes before merge?

@danfimov danfimov requested a review from s3rius December 1, 2025 10:56
@danfimov danfimov added the enhancement New feature or request label Dec 7, 2025
@s3rius s3rius merged commit 7ee894f into taskiq-python:master Dec 7, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants