Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Unified Diff: appengine/gce-backend/utilities.py

Issue 2713533002: Refactor task enqueuing (Closed)
Patch Set: Remove metric Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/gce-backend/metadata.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/gce-backend/utilities.py
diff --git a/appengine/gce-backend/utilities.py b/appengine/gce-backend/utilities.py
index a2f9e3c48b25f11d5646db1c15d47bb4c1ec880f..a5850f47691380628a135e4f853b9a0eb8af79c8 100644
--- a/appengine/gce-backend/utilities.py
+++ b/appengine/gce-backend/utilities.py
@@ -9,6 +9,8 @@ import json
from google.appengine.ext import ndb
+from components import utils
+
def batch_process_async(items, f, max_concurrent=50):
"""Processes asynchronous calls in parallel, but batched.
@@ -33,3 +35,19 @@ def batch_process_async(items, f, max_concurrent=50):
def compute_checksum(json_encodable):
"""Computes a checksum from a JSON-encodable dict or list."""
return hashlib.sha1(json.dumps(json_encodable, sort_keys=True)).hexdigest()
+
+
+def enqueue_task(taskqueue, key):
+ """Enqueues a task for the specified task queue to process the given key.
+
+ Args:
+ taskqueue: Name of the task queue.
+ key: ndb.Key to pass as a parameter to the task queue.
+ """
+ utils.enqueue_task(
+ '/internal/queues/%s' % taskqueue,
+ taskqueue,
+ params={
+ 'key': key.urlsafe(),
+ },
+ )
« no previous file with comments | « appengine/gce-backend/metadata.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698