How to use the celery.task.periodic_task function in celery

To help you get started, we’ve selected a few celery 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 YoLoveLife / DevOps / apps / manager / tasks.py View on Github external
@periodic_task(run_every=settings.MANAGER_HOST_TIME)
def aliyun2cmdb():
    from deveops.tools.aliyun_v2.request import ecs
    API = ecs.AliyunECSTool()
    for dict_models in API.tool_get_instances_models():
        host_query = Host.objects.filter(aliyun_id=dict_models['aliyun_id'], connect_ip=dict_models['connect_ip'])
        if not host_query.exists():
            host_maker(dict_models)
        else:
            host_updater(host_query, dict_models)
github dimagi / commcare-hq / custom / enikshay / integrations / nikshay / tasks.py View on Github external
@periodic_task(run_every=crontab(minute="0", hour="0"), queue='background_queue')
def send_nikshay_registration_notification_report():
    # send notification time report each midnight
    call_command('nikshay_registration_notification_time_report', 1, email=["mkangia@dimagi.com"])
github hydroshare / hydroshare / hs_core / tasks.py View on Github external
@periodic_task(ignore_result=True, run_every=crontab(minute=0, hour=0))
def sync_email_subscriptions():
    sixty_days = datetime.today() - timedelta(days=60)
    active_subscribed = UserProfile.objects.filter(email_opt_out=False,
                                                   user__last_login__gte=sixty_days,
                                                   user__is_active=True)
    sync_mailchimp(active_subscribed, settings.MAILCHIMP_ACTIVE_SUBSCRIBERS)
    subscribed = UserProfile.objects.filter(email_opt_out=False, user__is_active=True)
    sync_mailchimp(subscribed, settings.MAILCHIMP_SUBSCRIBERS)
github dimagi / commcare-hq / custom / ewsghana / tasks.py View on Github external
@periodic_task(run_every=crontab(day_of_week=3, hour=13, minute=54),
               queue='logistics_reminder_queue')
def third_soh_to_super():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        ThirdSOHReminder(domain).send()
github opps / opps / opps / containers / tasks.py View on Github external
@celery.task.periodic_task(run_every=timezone.timedelta(minutes=30))
def check_all_mirror_channel():
    from .models import Container, Mirror

    mirror = Container.objects.all().exclude(mirror_channel=None)
    for obj in mirror:
        try:
            for channel in obj.mirror_channel:
                Mirror.objects.get(channel=channel, container=mirror,
                                   site=mirror.site)
        except:
            obj.save()
github dimagi / commcare-hq / custom / ilsgateway / tasks.py View on Github external
@periodic_task(run_every=crontab(day_of_month="10-12", hour=5, minute=0),
               queue="logistics_reminder_queue")
def third_facility():
    """Last business day before or on 12th day of the submission month, 8:00am"""
    facility_randr_partial(12)
github transtats / transtats / dashboard / tasks.py View on Github external
@periodic_task(
    run_every=(crontab(minute=0, hour='19')),
    name="sync_packages_with_platform",
    ignore_result=True
)
def task_sync_packages_with_platform():
    """
    sync all packages with translation platform
    """

    package_manager = PackagesManager()
    reports_manager = ReportsManager()

    def _sync_package(pkg):
        package_manager.sync_update_package_stats(pkg)

    all_packages = []
github jarrekk / django-tmpl / application / project_name / tasks.py View on Github external
@periodic_task(run_every=crontab(minute='*/1'))
def task_test2():
    """example of schedule"""
    logger.info('task log2')
    return 'task2 ok'
github dimagi / commcare-hq / corehq / motech / repeaters / tasks.py View on Github external
@periodic_task(
    run_every=CHECK_REPEATERS_INTERVAL,
    queue=settings.CELERY_PERIODIC_QUEUE,
)
def check_repeaters():
    start = datetime.utcnow()
    six_hours_sec = 6 * 60 * 60
    six_hours_later = start + timedelta(seconds=six_hours_sec)

    # Long timeout to allow all waiting repeat records to be iterated
    check_repeater_lock = get_redis_lock(
        CHECK_REPEATERS_KEY,
        timeout=six_hours_sec,
        name=CHECK_REPEATERS_KEY,
    )
    if not check_repeater_lock.acquire(blocking=False):
        datadog_counter("commcare.repeaters.check.locked_out")
github bmbouter / worklog / worklog / tasks.py View on Github external
@periodic_task(run_every=crontab(hour=2, minute=0, day_of_week=[0,1,2,3,4,5,6]))
def generate_timesheets():
    if WorkPeriod.objects.filter(due_date=datetime.date.today()).count() > 0:
        subject = 'Timesheets are due'
        msg = 'Please visit: %s?date=%s' % (Site.objects.get_current().domain + urlreverse('timesheet_url'), datetime.date.today())
        recipients = []

        for admin in settings.ADMINS:
            recipients.append(admin[1])
        
        from_email = settings.DEFAULT_FROM_EMAIL
        django.core.mail.send_mail(subject, msg, from_email, recipients)