Browse Source

celery.task.control.ping: Proper "ping" implementation

Ask Solem 15 years ago
parent
commit
89520f3730
1 changed files with 18 additions and 0 deletions
  1. 18 0
      celery/task/control.py

+ 18 - 0
celery/task/control.py

@@ -44,6 +44,24 @@ def revoke(task_id, destination=None, **kwargs):
                                arguments={"task_id": task_id}, **kwargs)
 
 
+def ping(destination=None, timeout=1, **kwargs):
+    """Ping workers.
+
+    Returns answer from alive workers.
+
+    :keyword destination: If set, a list of the hosts to send the command to,
+        when empty broadcast to all workers.
+    :keyword connection: Custom broker connection to use, if not set,
+        a connection will be established automatically.
+    :keyword connect_timeout: Timeout for new connection if a custom
+        connection is not provided.
+    :keyword reply: Wait for and return the reply.
+    :keyword timeout: Timeout in seconds to wait for the reply.
+    :keyword limit: Limit number of replies.
+
+    """
+    return broadcast("ping", wait=True, destination=destination,
+                     timeout=timeout, **kwargs)
 
 
 def rate_limit(task_name, rate_limit, destination=None, **kwargs):