本文整理匯總了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)