<filename>dashboard/tasks.py
import dramatiq
from periodiq import PeriodiqMiddleware, cron
from dramatiq import get_broker

from .models import Job
from .models import Rpc

broker = get_broker()
broker.add_middleware(PeriodiqMiddleware(skip_delay=30))


@dramatiq.actor
def process_job(job_id):
    job = Job.objects.get(pk=job_id)
    job.process()

    job.status = Job.STATUS_DONE
    job.save()


@dramatiq.actor
def process_rpc(rpc_id):
    rpc = Rpc.objects.get(pk=rpc_id)
    # Call the dispatcher that will eventually send the request to the specified rpc function.
    rpc.process()

    rpc.status = Job.STATUS_DONE
    rpc.save()

@dramatiq.actor(periodic=cron('* * * * *'))
def scheduled():
    '''Example function that is configured to run at a regular interval.
    Must run scheduler from shell.
    e.g. $ python manage.py runperiodiq -v2
    Help specifying cron time use https://crontab.guru/
    '''
    print(f'Testing scheduled tasks')
<filename>dashboard/tasks.py
import dramatiq
from periodiq import PeriodiqMiddleware, cron
from dramatiq import get_broker

from .models import Job
from .models import Rpc

broker = get_broker()
broker.add_middleware(PeriodiqMiddleware(skip_delay=30))


@dramatiq.actor
def process_job(job_id):
    job = Job.objects.get(pk=job_id)
    job.process()

    job.status = Job.STATUS_DONE
    job.save()


@dramatiq.actor
def process_rpc(rpc_id):
    rpc = Rpc.objects.get(pk=rpc_id)
    # Call the dispatcher that will eventually send the request to the specified rpc function.
    rpc.process()

    rpc.status = Job.STATUS_DONE
    rpc.save()

@dramatiq.actor(periodic=cron('* * * * *'))
def scheduled():
    '''Example function that is configured to run at a regular interval.
    Must run scheduler from shell.
    e.g. $ python manage.py runperiodiq -v2
    Help specifying cron time use https://crontab.guru/
    '''
    print(f'Testing scheduled tasks')
# Call the dispatcher that will eventually send the request to the specified rpc function. Example function that is configured to run at a regular interval.     Must run scheduler from shell.     e.g. $ python manage.py runperiodiq -v2     Help specifying cron time use https://crontab.guru/