当前位置: 首页>>代码示例>>Python>>正文


Python Job.__new__方法代码示例

本文整理汇总了Python中apscheduler.job.Job.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Job.__new__方法的具体用法?Python Job.__new__怎么用?Python Job.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apscheduler.job.Job的用法示例。


在下文中一共展示了Job.__new__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _reconstitute_job

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def _reconstitute_job(self, job_state):
     job_state = pickle.loads(job_state)
     job = Job.__new__(Job)
     job.__setstate__(job_state)
     job._scheduler = self._scheduler
     job._jobstore_alias = self._alias
     return job
开发者ID:cychenyin,项目名称:windmill,代码行数:9,代码来源:mongodb.py

示例2: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def load_jobs(self):
     jobs = []
     for row in self.engine.execute(select([self.jobs_t])):
         try:
             job = Job.__new__(Job)
             job_dict = dict(row.items())
             job.__setstate__(job_dict)
             jobs.append(job)
         except Exception:
             job_name = job_dict.get("name", "(unknown)")
             logger.exception('Unable to restore job "%s"', job_name)
     self.jobs = jobs
开发者ID:roontoon,项目名称:headphones,代码行数:14,代码来源:sqlalchemy_store.py

示例3: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
    def load_jobs(self):
        jobs = []
        for job_dict in itervalues(self.store):
            try:
                job = Job.__new__(Job)
                job.__setstate__(job_dict)
                jobs.append(job)
            except Exception:
                job_name = job_dict.get('name', '(unknown)')
                logger.exception('Unable to restore job "%s"', job_name)

        self.jobs = jobs
开发者ID:Amelsfort,项目名称:CouchPotatoServer,代码行数:14,代码来源:shelve_store.py

示例4: _reconstitute_job

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def _reconstitute_job(self, row):
     '''
         code gen by shell cmd: cat a | awk -F '=' '{print $1}' | cut -c5- | awk '{ print "job."$1" = row."$1}'
         what in file a is the wm_jobs_t create statement which can be found in the current source code file
     '''
             
     conf = JobConf()
     conf.id = row.id
     conf.cmd = row.cmd
     conf.cron_str = row.cron_str
     conf.name = row.name
     conf.desc = row.desc
     conf.mails = row.mails
     conf.phones = row.phones
     conf.team = row.team
     conf.owner = row.owner
     conf.hosts = row.hosts
     conf.host_strategy = row.host_strategy
     conf.restore_strategy = row.restore_strategy
     conf.retry_strategy = row.retry_strategy
     conf.error_strategy = row.error_strategy
     conf.exist_strategy = row.exist_strategy
     conf.running_timeout_s = row.running_timeout_s
     conf.status = row.status
     conf.modify_time = row.modify_time
     conf.modify_user = row.modify_user
     conf.create_time = row.create_time
     conf.create_user = row.create_user
     conf.start_date = row.start_date
     conf.end_date = row.end_date
     conf.oupput_match_reg = row.oupput_match_reg 
     conf.next_run_time = row.next_run_time 
     
     job = Job.__new__(Job)
     job.conf = conf
     job.id = job.conf.id
     job._scheduler = self._scheduler
     job._jobstore_alias = self._alias
     job.trigger = self._create_trigger_by_conf(job) 
     t = apscheduler.util.local_timestamp_to_datetime(conf.next_run_time) if conf.next_run_time > 0 else None
     t = apscheduler.util.convert_to_ware_datetime(t, get_localzone(), 'conf.next_run_time' )
     state = {
          'version': 1,
          'conf': conf, 
          'id': conf.id, 
          'name': conf.name, 
          'next_run_time': t, 
     }
     
     job.__setstate__(state)
     
     return job
开发者ID:cychenyin,项目名称:windmill,代码行数:54,代码来源:mysqlstore.py

示例5: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def load_jobs(self):
     jobs = []
     for row in self.engine.execute(self.jobs_t.select()):
         try:
             job = Job.__new__(Job)
             job_dict = dict(row.items())
             job.__setstate__(job_dict)
             jobs.append(job)
         except Exception as e:
             print e
             traceback.print_exc(e)
             job_name = job_dict.get('name', '(unknown)')
             logger.exception('Unable to restore job "%s"', job_name)
     self.jobs = jobs
     return jobs
开发者ID:reedboat,项目名称:dcron,代码行数:17,代码来源:sqlalchemy_store.py

示例6: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def load_jobs(self):
     jobs = []
     for job_dict in self.collection.find():
         try:
             job = Job.__new__(Job)
             job_dict['id'] = job_dict.pop('_id')
             job_dict['trigger'] = pickle.loads(job_dict['trigger'])
             job_dict['args'] = pickle.loads(job_dict['args'])
             job_dict['kwargs'] = pickle.loads(job_dict['kwargs'])
             job.__setstate__(job_dict)
             jobs.append(job)
         except Exception:
             job_name = job_dict.get('name', '(unknown)')
             logger.exception('Unable to restore job "%s"', job_name)
     self.jobs = jobs
开发者ID:entone,项目名称:GeriCare,代码行数:17,代码来源:mongodb_store.py

示例7: pop

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
 def pop(self, now):
     item = self.redis.rpop(self.key)
     if item is None:
         return 0, '', None
     try:
         job_id, change_type, job_str = item.split('||')
         job_id = int(job_id)
         if job_str == 'None':
             job = None
         else:
             job_state = pickle.loads(job_str)
             job = Job.__new__(Job)
             job.__setstate__(job_state)
             job.compute_next_run_time(now)
         return job_id, change_type, job
     except:
         logger=logging.getLogger('cron.backend')
         logger.exception('sync item invalid')
         return 0, ''
开发者ID:reedboat,项目名称:dcron,代码行数:21,代码来源:jobstore.py

示例8: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
	def load_jobs(self):
		#continue standart execution
		jobs = []
		for job_dict in self.collection.find({'crecord_type': 'schedule'}):
			try:
				job = Job.__new__(Job)
				
				if job_dict['aaa_owner'] != 'root':
					if job_dict['kwargs']['task'] != 'task_reporting':
						raise ValueError("User %s isn\'t allow to run task %s" % (job_dict['aaa_owner'],job_dict['kwargs']['task']))
				
				#keep memory of id
				job_dict_id = job_dict['_id']
				
				job_dict['id'] = job_dict.pop('_id')
				
				if job_dict.has_key('runs'):
					job_dict['runs'] = job_dict['runs']
				else:
					job_dict['runs'] = 0
				
				job_dict['coalesce'] = False
				
				#try to get interval
				try:
					if job_dict['interval'] != None:
						job_dict['trigger'] = IntervalTrigger(timedelta(**job_dict['interval']))
				except Exception, err:
					pass
				
				#try to get simple
				try:
					if job_dict['date'] != None:
						job_dict['trigger'] = SimpleTrigger( datetime(*job_dict['date']))
				except Exception, err:
					pass
				
				#try to get crontab
				try:
					if job_dict['cron'] != None:
						job_dict['trigger'] = CronTrigger(**job_dict['cron'])
				except Exception, err:
					pass
开发者ID:Httqm,项目名称:canopsis,代码行数:45,代码来源:cmongodbjobstore.py

示例9: get_job

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
    def get_job(self, id):
        select = self.jobs_t.select().where(self.jobs_t.c.id == id)
        try:
            row = self.engine.execute(select).fetchone()
        except Exception as e:
            #todo
            logger.exception(e)

        if row:
            try:
                job = Job.__new__(Job)
                job_dict = dict(row.items())
                job.__setstate__(job_dict)
                return job
            except Exception:
                job_name = job_dict.get('name', 'unknown')
                logger.exception("Unable to restore job '%s'", job_name)

        return None
开发者ID:reedboat,项目名称:dcron,代码行数:21,代码来源:sqlalchemy_store.py

示例10: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
    def load_jobs(self):
        jobs = []
        keys = self.redis.keys(self.key_prefix + "*")
        pipeline = self.redis.pipeline()
        for key in keys:
            pipeline.hgetall(key)
        results = pipeline.execute()

        for job_dict in results:
            job_state = {}
            try:
                job = Job.__new__(Job)
                job_state = pickle.loads(job_dict["job_state".encode()])
                job_state["runs"] = long(job_dict["runs".encode()])
                dateval = job_dict["next_run_time".encode()].decode()
                job_state["next_run_time"] = datetime.strptime(dateval, "%Y-%m-%dT%H:%M:%S")
                job.__setstate__(job_state)
                jobs.append(job)
            except Exception:
                job_name = job_state.get("name", "(unknown)")
                logger.exception('Unable to restore job "%s"', job_name)
        self.jobs = jobs
开发者ID:Adelscott,项目名称:persomov,代码行数:24,代码来源:redis_store.py

示例11: load_jobs

# 需要导入模块: from apscheduler.job import Job [as 别名]
# 或者: from apscheduler.job.Job import __new__ [as 别名]
	def load_jobs(self):
		#continue standart execution
		jobs = []
		for job_dict in self.collection.find({'crecord_type': 'schedule'}):
			try:
				job = Job.__new__(Job)

				if job_dict['aaa_owner'] != 'account.root':
					if job_dict['kwargs']['task'] != 'task_reporting':
						raise ValueError("User %s isn\'t allow to run task %s" % (job_dict['aaa_owner'],job_dict['kwargs']['task']))

				#keep memory of id
				job_dict_id = job_dict['_id']

				job_dict['id'] = job_dict.pop('_id')

				if job_dict.has_key('runs'):
					job_dict['runs'] = job_dict['runs']
				else:
					job_dict['runs'] = 0

				job_dict['coalesce'] = False

				#try to get interval
				interval = job_dict.get('interval')
				if interval is not None:
					job_dict[TRIGGER] = IntervalTrigger(timedelta(**interval))
				else: #try to get simple
					date = job_dict.get('date')
					if date is not None:
						job_dict[TRIGGER] = SimpleTrigger( datetime(*date))
					else: #try to get crontab
						cron = job_dict.get('cron')
						if cron is not None:
							job_dict[TRIGGER] = CronTrigger(**cron)

				if TRIGGER not in job_dict:
					raise ValueError("No interval, nor date, nor cron is given in task %s".format(job_dict['crecord_name']))

				job_dict['next_run_time'] = job_dict['trigger'].get_next_fire_time(datetime.now())
				job_dict['args'] = job_dict['args']
				job_dict['kwargs'] = job_dict['kwargs']
				job_dict['max_runs'] = None
				job_dict['max_instances'] = 3
				job_dict['name'] = job_dict['crecord_name']
				job_dict['misfire_grace_time'] = 1

				job_dict['func_ref'] = 'apschedulerlibs.aps_to_celery:launch_celery_task'

				job.__setstate__(job_dict)
				jobs.append(job)

				#change flag to true
				self.collection.update({'_id':job_dict_id},{"$set":{'loaded':True, 'next_run_time': job_dict['next_run_time']}},True)

			except Exception:
				job_name = job_dict.get('name', '(unknown)')
				logger.exception('Unable to restore job "%s"', job_name)

		logger.info(' + %s jobs loaded' % len(jobs))
		self.jobs = jobs
开发者ID:EzanLTD,项目名称:canopsis,代码行数:63,代码来源:cmongodbjobstore.py


注:本文中的apscheduler.job.Job.__new__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。