Python django_rq.get_scheduler() Examples

The following are code examples for showing how to use django_rq.get_scheduler(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: project-status-dashboard   Author: cmheisel   File: apps.py    (license) View Source Project 6 votes vote down vote up
def ready(self):
        """Do this when the app is ready."""
        cache_key = 'dashboard.config.jobs_scheduled'
        scheduled = cache.get(cache_key, False)

        if not scheduled and settings.RQ_QUEUES.get('default', {}).get('ASYNC', True):
            logger.info("Scheduling jobs")
            scheduler = django_rq.get_scheduler('default')
            scheduler.schedule(
                scheduled_time=datetime.utcnow(),
                func='dashboard.jobs.generate_dashboard',
                interval=INTERVAL,
                result_ttl=INTERVAL + 30
            )
            cache.set(cache_key, True, INTERVAL)
        return True 
Example 2
Project: socialhome   Author: jaywink   File: apps.py    (GNU Affero General Public License v3.0) View Source Project 5 votes vote down vote up
def ready(self):
        scheduler = django_rq.get_scheduler("default")

        # Delete any existing jobs in the scheduler when the app starts up
        for job in scheduler.get_jobs():
            job.delete()

        # Queue tasks
        streams_tasks(scheduler) 
Example 3
Project: DCRM   Author: 82Flex   File: rqscheduler.py    (license) View Source Project 5 votes vote down vote up
def handle(self, *args, **options):
        pid = options.get('pid')
        if pid:
            with open(os.path.expanduser(pid), "w") as fp:
                fp.write(str(os.getpid()))

        scheduler = get_scheduler(
            name=options.get('queue'), interval=options.get('interval'))
        scheduler.run() 
Example 4
Project: mercure   Author: synhack   File: helpers.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        super(RQMixin, self).setUp()
        get_connection().flushdb()
        self.scheduler = get_scheduler() 
Example 5
Project: django-rq-scheduler   Author: istrategylabs   File: models.py    (license) View Source Project 5 votes vote down vote up
def scheduler(self):
        return django_rq.get_scheduler(self.queue)