本文整理汇总了Python中job.Job.dump方法的典型用法代码示例。如果您正苦于以下问题:Python Job.dump方法的具体用法?Python Job.dump怎么用?Python Job.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类job.Job
的用法示例。
在下文中一共展示了Job.dump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFromDB
# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import dump [as 别名]
def getFromDB():
#l = {}
#cur_iter = Job.currentIteration()
logging.info("Get all jobs from db")
#l['iteration'] = cur_iter
jobs = Job.getAll()
return Job.dump(jobs)
示例2: put
# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import dump [as 别名]
def put(self):
logging.info('put all jobs received')
if memcache.get(PutAllJobs._lockKey) is not None:
logging.warn('jobs locked by another caller')
self.error(204)
return
else:
memcache.set(PutAllJobs._lockKey, True, 5) #5s
data_string = self.request.body
decoded = json.loads(data_string)
logging.info(json.dumps(decoded, indent=2))
if decoded.has_key('jobs'):
jobs = decoded['jobs']
logging.info('count jobs: ' + str(len(jobs)))
data = Job.getAll()
if data is not None:
if data.count(1) > 0:
arch = Archive(key_name=str(data[0].iteration))
arch.jobs = Job.dump(data)
pop = Pop.all().get() #get current population to archive
if pop is not None:
arch.pop = pop.pop
arch.vals = pop.vals
arch.put()
Job.putAll(jobs)
memcache.delete(GetAllJobs.cachekey)
memcache.delete(PutAllJobs._lockKey)
email = self.request.get("email")
if email:
logging.info(email)
from google.appengine.api import mail
mail.send_mail(sender=email, to=email, subject="New iteration started", body=data_string)