def post(self): task = ExportTask() task.put() retry_options = taskqueue.TaskRetryOptions(task_retry_limit=0) queue_task = taskqueue.Task(url='/export/run', params={"task":task.key.urlsafe()}, retry_options=retry_options) queue_task.add() result = {"message" : "Waiting for task to start..", "id" : task.key.urlsafe()} self.response.headers['Content-Type'] = "application/json" self.response.write(json.dumps(result))
def post(self): task = ExportTask() task.put() retry_options = taskqueue.TaskRetryOptions(task_retry_limit=0) queue_task = taskqueue.Task(url='/export/run', params={"task": task.key.urlsafe()}, retry_options=retry_options) queue_task.add() result = { "message": "Waiting for task to start..", "id": task.key.urlsafe() } self.response.headers['Content-Type'] = "application/json" self.response.write(json.dumps(result))
def get(self, filename): export = ExportTask.query(UserImage.filename == filename).get() if not export: self.error(404) else: self.send_blob(filestore.get_blob_key(export.filename))
def cleanup_old_export_tasks(self): #Lets delete any old export tasks hanging around... old_deleted = 0 for ex in ExportTask.query().fetch(): if ex.status in ('finished', 'failed'): try: filestore.delete(ex.filename) except: pass ex.key.delete() old_deleted += 1 if old_deleted > 0: logging.info('Deleted %s old export tasks' % old_deleted)