當前位置: 首頁>>代碼示例>>Python>>正文


Python base.ConflictingIdError方法代碼示例

本文整理匯總了Python中apscheduler.jobstores.base.ConflictingIdError方法的典型用法代碼示例。如果您正苦於以下問題:Python base.ConflictingIdError方法的具體用法?Python base.ConflictingIdError怎麽用?Python base.ConflictingIdError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apscheduler.jobstores.base的用法示例。


在下文中一共展示了base.ConflictingIdError方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        insert = self.jobs_t.insert().values(**{
            'id': job.id,
            'next_run_time': datetime_to_utc_timestamp(job.next_run_time),
            'job_state': pickle.dumps(job.__getstate__(),
                                      self.pickle_protocol),
            'service_id': self.service_id,
            'tag': jsonutils.dumps(self.tag)
        })
        try:
            self.engine.execute(insert)
        except IntegrityError:
            raise ConflictingIdError(job.id) 
開發者ID:openstack,項目名稱:watcher,代碼行數:15,代碼來源:job_store.py

示例2: add_date_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_date_job(datetime_str, job_id, task, args_):
    global g_main_scheduler
    run_time = datetime.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S.%fZ')
    run_time = run_time - timedelta(minutes=30)

    try:
        g_main_scheduler.add_job(task, args=args_, id=job_id, name=task.__qualname__, next_run_time=run_time, misfire_grace_time=3600*2)
    except ConflictingIdError:
        g_main_scheduler.modify_job(job_id, func=task, args=args_, name=task.__qualname__, next_run_time=run_time)
    log_jobs() 
開發者ID:HalfMAI,項目名稱:AutoYtB,代碼行數:12,代碼來源:scheduler.py

示例3: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        self._ensure_paths()
        node_path = os.path.join(self.path,  str(job.id))
        value = {
            'next_run_time': datetime_to_utc_timestamp(job.next_run_time),
            'job_state': job.__getstate__()
        }
        data = pickle.dumps(value, self.pickle_protocol)
        try:
            self.client.create(node_path, value=data)
        except NodeExistsError:
            raise ConflictingIdError(job.id) 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:14,代碼來源:zookeeper.py

示例4: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        if self.redis.hexists(self.jobs_key, job.id):
            raise ConflictingIdError(job.id)

        with self.redis.pipeline() as pipe:
            pipe.multi()
            pipe.hset(self.jobs_key, job.id, pickle.dumps(job.__getstate__(),
                                                          self.pickle_protocol))
            if job.next_run_time:
                pipe.zadd(self.run_times_key, datetime_to_utc_timestamp(job.next_run_time), job.id)
            pipe.execute() 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:13,代碼來源:redis.py

示例5: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        insert = self.jobs_t.insert().values(**{
            'id': job.id,
            'next_run_time': datetime_to_utc_timestamp(job.next_run_time),
            'job_state': pickle.dumps(job.__getstate__(), self.pickle_protocol)
        })
        try:
            self.engine.execute(insert)
        except IntegrityError:
            raise ConflictingIdError(job.id) 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:12,代碼來源:sqlalchemy.py

示例6: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        if job.id in self._jobs_index:
            raise ConflictingIdError(job.id)

        timestamp = datetime_to_utc_timestamp(job.next_run_time)
        index = self._get_job_index(timestamp, job.id)
        self._jobs.insert(index, (job, timestamp))
        self._jobs_index[job.id] = (job, timestamp) 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:10,代碼來源:memory.py

示例7: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        try:
            self.collection.insert({
                '_id': job.id,
                'next_run_time': datetime_to_utc_timestamp(job.next_run_time),
                'job_state': Binary(pickle.dumps(job.__getstate__(), self.pickle_protocol))
            })
        except DuplicateKeyError:
            raise ConflictingIdError(job.id) 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:11,代碼來源:mongodb.py

示例8: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job(self, job):
        if self.redis.hexists(self.jobs_key, job.id):
            raise ConflictingIdError(job.id)

        with self.redis.pipeline() as pipe:
            pipe.multi()
            pipe.hset(self.jobs_key, job.id, pickle.dumps(job.__getstate__(),
                                                          self.pickle_protocol))
            if job.next_run_time:
                pipe.zadd(self.run_times_key,
                          {job.id: datetime_to_utc_timestamp(job.next_run_time)})

            pipe.execute() 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:15,代碼來源:redis.py

示例9: add_scheduled_commands

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_scheduled_commands(
        commands: Union[ScheduledCommand, List[ScheduledCommand]], *,
        job_id: str, ctx: Dict[str, Any],
        trigger: str,
        replace_existing: bool = False,
        misfire_grace_time: int = 360,
        apscheduler_kwargs: Dict[str, Any] = None,
        **trigger_args) -> Job:
    """
    Add commands to scheduler for scheduled execution.

    :param commands: commands to add, can be a single ScheduledCommand
    :param job_id: job id, using of make_job_id() is recommended
    :param ctx: context dict
    :param trigger: same as APScheduler
    :param replace_existing: same as APScheduler
    :param misfire_grace_time: same as APScheduler
    :param apscheduler_kwargs: other APScheduler keyword args
    :param trigger_args: same as APScheduler
    """
    commands = [commands] \
        if isinstance(commands, ScheduledCommand) else commands

    try:
        return await aio.run_sync_func(
            nb.scheduler.add_job,
            _scheduled_commands_callback,
            id=job_id,
            trigger=trigger, **trigger_args,
            kwargs={'ctx': ctx, 'commands': commands},
            replace_existing=replace_existing,
            misfire_grace_time=misfire_grace_time,
            **(apscheduler_kwargs or {}))
    except ConflictingIdError:
        raise JobIdConflictError(job_id) 
開發者ID:cczu-osa,項目名稱:aki,代碼行數:37,代碼來源:scheduler.py

示例10: add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def add_job():
    """Adds a new job."""

    data = request.get_json(force=True)

    try:
        job = current_app.apscheduler.add_job(**data)
        return jsonify(job)
    except ConflictingIdError:
        return jsonify(dict(error_message='Job %s already exists.' % data.get('id')), status=409)
    except Exception as e:
        return jsonify(dict(error_message=str(e)), status=500) 
開發者ID:viniciuschiele,項目名稱:flask-apscheduler,代碼行數:14,代碼來源:api.py

示例11: _real_add_job

# 需要導入模塊: from apscheduler.jobstores import base [as 別名]
# 或者: from apscheduler.jobstores.base import ConflictingIdError [as 別名]
def _real_add_job(self, job, jobstore_alias, replace_existing):
        """
        :param Job job: the job to add
        :param bool replace_existing: ``True`` to use update_job() in case the job already exists
            in the store

        """
        # Fill in undefined values with defaults
        replacements = {}
        for key, value in six.iteritems(self._job_defaults):
            if not hasattr(job, key):
                replacements[key] = value

        # Calculate the next run time if there is none defined
        if not hasattr(job, 'next_run_time'):
            now = datetime.now(self.timezone)
            replacements['next_run_time'] = job.trigger.get_next_fire_time(None, now)

        # Apply any replacements
        job._modify(**replacements)

        # Add the job to the given job store
        store = self._lookup_jobstore(jobstore_alias)
        try:
            store.add_job(job)
        except ConflictingIdError:
            if replace_existing:
                store.update_job(job)
            else:
                raise

        # Mark the job as no longer pending
        job._jobstore_alias = jobstore_alias

        # Notify listeners that a new job has been added
        event = JobEvent(EVENT_JOB_ADDED, job.id, jobstore_alias)
        self._dispatch_event(event)

        self._logger.info('Added job "%s" to job store "%s"', job.name, jobstore_alias)

        # Notify the scheduler about the new job
        if self.state == STATE_RUNNING:
            self.wakeup() 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:45,代碼來源:base.py


注:本文中的apscheduler.jobstores.base.ConflictingIdError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。