Beispiel #1
0
    def run_job(cls, job_class_path, job_id, *args, **kwargs):
        # An execution ID is created
        execution_id = utils.generate_uuid()

        datastore = utils.get_datastore_instance()
        datastore.add_execution(
            execution_id,
            job_id,
            constants.EXECUTION_STATUS_SCHEDULED,
            description=job.JobBase.get_scheduled_description())
        try:
            job_class = utils.import_from_path(job_class_path)
            datastore.update_execution(
                execution_id,
                state=constants.EXECUTION_STATUS_SCHEDULED,
                description=job_class.get_scheduled_description())
            cls.run_scheduler_job(job_class, job_id, execution_id, *args,
                                  **kwargs)
        except Exception as e:
            logger.exception(e)
            datastore.update_execution(
                execution_id,
                state=constants.EXECUTION_STATUS_SCHEDULED_ERROR,
                description=job.JobBase.get_scheduled_error_description())
            return None
        return execution_id
Beispiel #2
0
 def run_job(cls, job_class_path, job_id, *args, **kwargs):
     execution_id = utils.generate_uuid()
     datastore = utils.get_datastore_instance()
     datastore.add_execution(execution_id, job_id,
                             constants.EXECUTION_STATUS_SCHEDULED,
                             description=job.JobBase.get_scheduled_description())
     try:
         job_class = utils.import_from_path(job_class_path)
         datastore.update_execution(execution_id, state=constants.EXECUTION_STATUS_SCHEDULED,
                                    description=job_class.get_scheduled_description())
         cls.run_scheduler_job(job_class, job_id, execution_id, *args, **kwargs)
     except Exception as e:
         logger.exception(e)
         datastore.update_execution(execution_id,
                                    state=constants.EXECUTION_STATUS_SCHEDULED_ERROR,
                                    description=job.JobBase.get_scheduled_error_description())
         return None
     return execution_id
    def __init__(self):
        JOB_STORES = {
            'default': utils.get_datastore_instance()
        }

        JOB_DEFAULT = {
            'coalesce': settings.JOB_COALESCE,
            'misfire_grace_time': settings.JOB_MISFIRE_GRACE_SEC,
            'max_instances': settings.JOB_MAX_INSTANCES
        }

        EXECUTORS = {
            'default': pool.ThreadPoolExecutor(settings.THREAD_POOL_SIZE)
        }

        scheduler_class = utils.import_from_path(settings.SCHEDULER_CLASS)
        self.sched = scheduler_class(
            jobstores=JOB_STORES, executors=EXECUTORS, job_defaults=JOB_DEFAULT,
            logger=logger, timezone=settings.TIMEZONE)
    def __init__(self):
        JOB_STORES = {'default': utils.get_datastore_instance()}

        JOB_DEFAULT = {
            'coalesce': settings.JOB_COALESCE,
            'misfire_grace_time': settings.JOB_MISFIRE_GRACE_SEC,
            'max_instances': settings.JOB_MAX_INSTANCES
        }

        EXECUTORS = {
            'default': pool.ThreadPoolExecutor(settings.THREAD_POOL_SIZE)
        }

        scheduler_class = utils.import_from_path(settings.SCHEDULER_CLASS)
        self.sched = scheduler_class(jobstores=JOB_STORES,
                                     executors=EXECUTORS,
                                     job_defaults=JOB_DEFAULT,
                                     logger=logger,
                                     timezone=settings.TIMEZONE)