Closed arbazkiraak closed 4 years ago
dynamic schedule task
from huey import crontab from huey.contrib.djhuey import periodic_task, task @task() def schedule_message(project_id,cron_minutes,cron_hours='*'): def wrapper(): SubdomainScanner(project_id) schedule = crontab(cron_minutes,cron_hours) task_name = 'subdomain_scanner_task_{}'.format(project_id) periodic_task(schedule,name=task_name)(wrapper)
from .tasks import * schedule_message('google.com','*/1')
python3 manage.py run_huey -w 2 [2020-02-27 06:00:11,428] INFO:huey.consumer:MainThread:Huey consumer started with 2 thread, PID 1412 at 2020-02-27 06:00:11.428149 [2020-02-27 06:00:11,428] INFO:huey.consumer:MainThread:Scheduler runs every 1 second(s). [2020-02-27 06:00:11,428] INFO:huey.consumer:MainThread:Periodic tasks are enabled. [2020-02-27 06:00:11,429] INFO:huey.consumer:MainThread:The following commands are available: + mainapp.tasks.schedule_message
https://huey.readthedocs.io/en/latest/guide.html#dynamic-periodic-tasks
Hello @coleifer ,
It works, I wanted to ask how to dynamically remove or update the schedule_message by their task_name ?
schedule_message
dynamic schedule task
along with the periodic interval of 1 minute in the crontab. But it doesn't seem to execute the task for every 1 minute. What am I doing wrong?