Browse Source

Added some more FAQs from stack overflow

Ask Solem 14 years ago
parent
commit
e3c9e49a3e
1 changed files with 79 additions and 26 deletions
  1. 79 26
      FAQ

+ 79 - 26
FAQ

@@ -239,30 +239,6 @@ waiting tasks you have to stop all the workers, and then discard the tasks
 using ``discard_all``.
 
 
-Windows: The ``-B`` / ``--beat`` option to celeryd doesn't work?
-----------------------------------------------------------------
-**Answer**: That's right. Run ``celerybeat`` and ``celeryd`` as separate
-services instead.
-
-Tasks
-=====
-
-How can I reuse the same connection when applying tasks?
---------------------------------------------------------
-
-**Answer**: See :doc:`userguide/executing`.
-
-Can I execute a task by name?
------------------------------
-
-**Answer**: Yes. Use :func:`celery.execute.send_task`.
-You can also execute a task by name from any language
-that has an AMQP client.
-
-    >>> from celery.execute import send_task
-    >>> send_task("tasks.add", args=[2, 2], kwargs={})
-    <AsyncResult: 373550e8-b9a0-4666-bc61-ace01fa4f91d>
-
 Results
 =======
 
@@ -389,8 +365,56 @@ using the STOMP backend:
 
     * mandatory
 
-Features
-========
+Tasks
+=====
+
+How can I reuse the same connection when applying tasks?
+--------------------------------------------------------
+
+**Answer**: See :doc:`userguide/executing`.
+
+Can I execute a task by name?
+-----------------------------
+
+**Answer**: Yes. Use :func:`celery.execute.send_task`.
+You can also execute a task by name from any language
+that has an AMQP client.
+
+    >>> from celery.execute import send_task
+    >>> send_task("tasks.add", args=[2, 2], kwargs={})
+    <AsyncResult: 373550e8-b9a0-4666-bc61-ace01fa4f91d>
+
+
+How can I get the task id of the current task?
+----------------------------------------------
+
+**Answer**: Celery does set some default keyword arguments if the task
+accepts them (you can accept them by either using ``**kwargs``, or list them
+specifically)::
+
+    @task
+    def mytask(task_id=None):
+        cache.set(task_id, "Running")
+
+The default keyword arguments are documented here:
+http://celeryq.org/docs/userguide/tasks.html#default-keyword-arguments
+
+Can I specify a custom task_id?
+-------------------------------
+
+**Answer**: Yes. Use the ``task_id`` argument to
+:meth:`~celery.execute.apply_async`::
+
+    >>> task.apply_async(args, kwargs, task_id="...")
+
+Can I use natural task ids?
+---------------------------
+
+**Answer**: Yes, but make sure it is unique, as the behavior
+for two tasks existing with the same id is undefined.
+
+The world will probably not explode, but at the worst
+they can overwrite each others results.
 
 How can I run a task once another task has finished?
 ----------------------------------------------------
@@ -563,3 +587,32 @@ and they will not be re-run unless you have the ``acks_late`` option set.
 How do I run celeryd in the background on [platform]?
 -----------------------------------------------------
 **Answer**: Please see :doc:`cookbook/daemonizing`.
+
+Windows
+=======
+
+celeryd keeps spawning processes at startup
+-------------------------------------------
+
+**Answer**: This is a known issue on Windows.
+You have to start celeryd with the command::
+
+    $ python -m celeryd.bin.celeryd
+
+Any additional arguments can be appended to this command.
+
+See http://bit.ly/bo9RSw
+
+The ``-B`` / ``--beat`` option to celeryd doesn't work?
+----------------------------------------------------------------
+**Answer**: That's right. Run ``celerybeat`` and ``celeryd`` as separate
+services instead.
+
+``django-celery`` can’t find settings?
+--------------------------------------
+
+**Answer**: You need to specify the ``--settings`` argument to ``manage.py``::
+
+    $ python manage.py celeryd start --settings=settings
+
+See http://bit.ly/bo9RSw