How to use the arq.cron function in arq

To help you get started, we’ve selected a few arq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelcolvin / arq / tests / fixtures.py View on Github external
    @cron(hour=3, minute=0, second=0, run_at_startup=True)
    async def save_foobar(self):
        with open('foobar', 'w') as f:
            f.write(f'foobar the value')
github samuelcolvin / arq / tests / fixtures.py View on Github external
    @cron(hour=3, minute=0, second=0)
    async def save_spam(self):
        with open('spam', 'w') as f:
            f.write(f'spam the value')
github samuelcolvin / arq / tests / fixtures.py View on Github external
    @cron(hour=3, minute=0, second=0, unique=False)
    async def save_not_unique(self):
        with open('not_unique', 'w') as f:
            f.write(f'not_unique the value')
github samuelcolvin / nosht / py / shared / emails / main.py View on Github external
    @cron(minute={5, 35})  # run twice per hour to make sure of sending if something is wrong at one send time
    async def send_event_host_updates_final(self):
        """
        Send an email to the host of an event 4-5 hours before the event is scheduled to start.
        """
        async with self.pg.acquire() as conn:
            # get events for which updates need to be sent
            events = await conn.fetch(
                """
                SELECT
                  e.id, e.name, e.host AS host_user_id,
                  event_link(cat.slug, e.slug, e.public, $1) AS event_link,
                  cat.name AS cat_name, cat.slug AS cat_slug,
                  cat.company AS company_id
                FROM events AS e
                JOIN categories AS cat ON e.category = cat.id
                WHERE e.status = 'published' AND
github samuelcolvin / nosht / py / shared / emails / main.py View on Github external
    @cron(minute=30)
    async def send_event_reminders(self):
        """
        Send emails to guest of an event 24(ish) hours before the event is expected to start.
        """
        async with self.pg.acquire() as conn:
            # get events for which reminders need to be send
            events = await conn.fetch(
                """
                SELECT
                  e.id, e.name, e.short_description, e.start_ts, e.timezone, e.duration,
                  e.location_name, e.location_lat, e.location_lng,
                  cat.name AS cat_name, cat.slug AS cat_slug, cat.company AS company_id,
                  event_link(cat.slug, e.slug, e.public, $1) AS event_link,
                  full_name(uh.first_name, uh.last_name) AS host_name
                FROM events AS e
                JOIN users AS uh on e.host = uh.id
github samuelcolvin / arq / docs / examples / cron.py View on Github external
from arq import cron

async def run_regularly(ctx):
    print('run foo job at 9.12am, 12.12pm and 6.12pm')

class WorkerSettings:
    cron_jobs = [
        cron(run_regularly, hour={9, 12, 18}, minute=12)
    ]
github samuelcolvin / nosht / py / shared / emails / main.py View on Github external
    @cron(hour=7, minute=30)
    async def send_event_host_updates(self):
        """
        Send emails to hosts of events every day before the event with details of bookings.
        """
        async with self.pg.acquire() as conn:
            # get events for which updates need to be sent
            events = await conn.fetch(
                """
                SELECT
                  e.id, e.name, (e.start_ts AT TIME ZONE e.timezone)::date AS event_date, e.host AS host_user_id,
                  event_link(cat.slug, e.slug, e.public, $1) AS event_link,
                  cat.name AS cat_name, cat.slug AS cat_slug,
                  cat.company AS company_id, co.currency AS currency,
                  t_all.tickets_booked, e.ticket_limit, t_all.total_income, t_recent.tickets_booked_24h
                FROM events AS e
                JOIN categories AS cat ON e.category = cat.id