本文整理汇总了Python中twext.enterprise.jobs.jobitem.JobItem.load方法的典型用法代码示例。如果您正苦于以下问题:Python JobItem.load方法的具体用法?Python JobItem.load怎么用?Python JobItem.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twext.enterprise.jobs.jobitem.JobItem
的用法示例。
在下文中一共展示了JobItem.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkTemporaryFailure
# 需要导入模块: from twext.enterprise.jobs.jobitem import JobItem [as 别名]
# 或者: from twext.enterprise.jobs.jobitem.JobItem import load [as 别名]
def checkTemporaryFailure(self, results):
"""
Check to see whether whether a temporary failure should be raised as opposed to continuing on with a permanent failure.
@param results: set of results gathered in L{extractSchedulingResponse}
@type results: L{list}
"""
if all([result[1] == iTIPRequestStatus.MESSAGE_PENDING_CODE for result in results]):
job = yield JobItem.load(self.transaction, self.jobID)
if job.failed >= config.Scheduling.Options.WorkQueues.MaxTemporaryFailures:
# Set results to SERVICE_UNAVAILABLE
for ctr, result in enumerate(results):
results[ctr] = (result[0], iTIPRequestStatus.SERVICE_UNAVAILABLE_CODE,)
returnValue(None)
else:
raise JobTemporaryError(config.Scheduling.Options.WorkQueues.TemporaryFailureDelay)
示例2: afterWork
# 需要导入模块: from twext.enterprise.jobs.jobitem import JobItem [as 别名]
# 或者: from twext.enterprise.jobs.jobitem.JobItem import load [as 别名]
def afterWork(self):
"""
A hook that gets called after the L{WorkItem} does its real work. This can be used
for common clean-up behaviors. The base implementation does nothing.
"""
yield super(ScheduleWorkMixin, self).afterWork()
# Find the next item and schedule to run immediately after this.
# We only coalesce ScheduleOrganizerSendWork.
if self.workType() == ScheduleOrganizerSendWork.workType():
all = yield self.baseWork.query(
self.transaction,
(ScheduleWork.icalendarUID == self.icalendarUID).And(ScheduleWork.workID != self.workID),
order=ScheduleWork.workID,
limit=1,
)
if all:
work = all[0]
if work.workType == self.workType():
job = yield JobItem.load(self.transaction, work.jobID)
yield job.update(notBefore=datetime.datetime.utcnow())
log.debug("ScheduleOrganizerSendWork - promoted job: {id}, UID: '{uid}'", id=work.workID, uid=self.icalendarUID)