darq icon indicating copy to clipboard operation
darq copied to clipboard

Add ability to passing args to task during creating cron job

Open foobic opened this issue 5 years ago • 1 comments

It would be great if there was an opportunity to pass arguments to task during creating cron job

Example:

@darq.task
async def print_name(name: str = 'John'):
    print(name)


cron_jobs = (
    cron(print_name, hour=3, task_kwargs=dict(name='Lucas')),
)

foobic avatar Sep 01 '20 12:09 foobic

Will do.

But for this moment it can be done by wrapping existing task into wrapper with params:

@darq.task
async def print_name(name: str = 'John'):
    print(name)


@darq.task
async def print_alex_name():
    return await print_name('Alex')


cron_jobs = (
    cron(print_alex_name, hour=3),
)

seedofjoy avatar Sep 17 '20 07:09 seedofjoy