Last active
April 21, 2016 12:25
-
-
Save topless/c6b3b15943cac9c19b2b02f4bcb44774 to your computer and use it in GitHub Desktop.
Deferred app engine queue, to iterate though all entities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api_v1.resource('/run/patch', endpoint='api.run.patch') | |
class PatchRunAPI(restful.Resource): | |
def get(self): | |
deferred.defer(update_run_task) | |
return flask.jsonify({ | |
'result': 'The queues started patching all run models!!', | |
'status': 'success', | |
}) | |
def update_run_task(next_cursor=None): | |
run_dbs, next_cursor = util.get_dbs(model.Run.query(), cursor=next_cursor) | |
if run_dbs: | |
for run_db in run_dbs: | |
logging.warning(run_db) | |
logging.warning("Patched %d entities." % len(run_dbs)) | |
if next_cursor['next'] is not None: | |
deferred.defer(update_run_task, next_cursor['next']) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
something like this..