def add_to_queue(self, url=None, target_state='queued', countdown=0):
"""
Adds job to task queue and transactionally updates state to 'queued'
and saves job.
Does nothing if state is not 'scheduled'.
"""
if self.state != 'scheduled':
logging.warn('tried to add job {} with state {}, to queue, '
'doing nothing'.format(self.key, self.state))
return
if url is None:
url = self.queue_url
logging.debug(u'scheduling job {} for {}'.format(self.key,
self.user_email))
taskqueue.add(url=url,
payload=json.dumps({'key': self.key.urlsafe()}),
queue_name=self.queue_name,
countdown=countdown,
transactional=True)
self.state = target_state
self.put()
评论列表
文章目录