Permalink
Browse files

Documentation improvements

  • Loading branch information...
1 parent c34097d commit 823f45cf0a046dd7262a33ca6f3bdb5ccb5524c5 Ask Solem committed Oct 28, 2010
View
@@ -1,16 +1,16 @@
-Installing celery
+Installing Celery
=================
-You can install `celery` either via the Python Package Index (PyPI)
+You can install Celery either via the Python Package Index (PyPI)
or from source.
To install using `pip`::
- $ pip install celery
+ $ pip install Celery
To install using `easy_install`::
- $ easy_install celery
+ $ easy_install Celery
If you have downloaded a source tarball you can install it
by doing the following::
View
@@ -1,3 +1,13 @@
+"""
+celery.app
+==========
+
+Celery Application.
+
+:copyright: (c) 2009 - 2010 by Ask Solem.
+:license: BSD, see LICENSE for more details.
+
+"""
import os
from inspect import getargspec
@@ -6,44 +16,24 @@
from celery.app import base
from celery.utils.functional import wraps
+# Apps with the :attr:`~celery.app.base.BaseApp.set_as_current` attribute
+# sets this, so it will always contain the last instantiated app,
+# and is the default app returned by :func:`app_or_default`.
_current_app = None
class App(base.BaseApp):
"""Celery Application.
- Inherits from :class:`celery.app.base.BaseApp`.
-
:keyword loader: The loader class, or the name of the loader class to use.
- Default is :class:`celery.loaders.app.AppLoader`.
+ Default is :class:`celery.loaders.app.AppLoader`.
:keyword backend: The result store backend class, or the name of the
- backend class to use. Default is the value of the
- :setting:`CELERY_RESULT_BACKEND` setting.
-
- .. attribute:: amqp
-
- Sending/receiving messages.
- See :class:`celery.app.amqp.AMQP`.
-
- .. attribute:: backend
-
- Storing/retreiving task state.
- See :class:`celery.backend.base.BaseBackend`.
+ backend class to use. Default is the value of the
+ :setting:`CELERY_RESULT_BACKEND` setting.
- .. attribute:: conf
+ .. seealso::
- Current configuration. Supports both the dict interface and
- attribute access.
-
- .. attribute:: control
-
- Controlling worker nodes.
- See :class:`celery.task.control.Control`.
-
- .. attribute:: log
-
- Logging.
- See :class:`celery.log.Logging`.
+ The app base class; :class:`~celery.app.base.BaseApp`.
"""
@@ -59,53 +49,55 @@ def create_task_cls(self):
return create_task_cls(app=self)
def Worker(self, **kwargs):
- """Create new :class:`celery.apps.worker.Worker` instance."""
+ """Create new :class:`~celery.apps.worker.Worker` instance."""
from celery.apps.worker import Worker
return Worker(app=self, **kwargs)
def Beat(self, **kwargs):
- """Create new :class:`celery.apps.beat.Beat` instance."""
+ """Create new :class:`~celery.apps.beat.Beat` instance."""
from celery.apps.beat import Beat
return Beat(app=self, **kwargs)
def TaskSet(self, *args, **kwargs):
- """Create new :class:`celery.task.sets.TaskSet`."""
+ """Create new :class:`~celery.task.sets.TaskSet`."""
from celery.task.sets import TaskSet
kwargs["app"] = self
return TaskSet(*args, **kwargs)
def worker_main(self, argv=None):
+ """Run :program:`celeryd` using `argv`. Uses :data:`sys.argv`
+ if `argv` is not specified."""
from celery.bin.celeryd import WorkerCommand
return WorkerCommand(app=self).execute_from_commandline(argv)
def task(self, *args, **options):
"""Decorator to create a task class out of any callable.
- Examples:
+ .. admonition:: Examples
- .. code-block:: python
+ .. code-block:: python
- @task()
- def refresh_feed(url):
- return Feed.objects.get(url=url).refresh()
+ @task()
+ def refresh_feed(url):
+ return Feed.objects.get(url=url).refresh()
- With setting extra options and using retry.
+ With setting extra options and using retry.
- .. code-block:: python
+ .. code-block:: python
- @task(exchange="feeds")
- def refresh_feed(url, **kwargs):
- try:
- return Feed.objects.get(url=url).refresh()
- except socket.error, exc:
- refresh_feed.retry(args=[url], kwargs=kwargs, exc=exc)
+ @task(exchange="feeds")
+ def refresh_feed(url, **kwargs):
+ try:
+ return Feed.objects.get(url=url).refresh()
+ except socket.error, exc:
+ refresh_feed.retry(args=[url], kwargs=kwargs, exc=exc)
- Calling the resulting task:
+ Calling the resulting task:
- >>> refresh_feed("http://example.com/rss") # Regular
- <Feed: http://example.com/rss>
- >>> refresh_feed.delay("http://example.com/rss") # Async
- <AsyncResult: 8998d0f4-da0b-4669-ba03-d5ab5ac6ad5d>
+ >>> refresh_feed("http://example.com/rss") # Regular
+ <Feed: http://example.com/rss>
+ >>> refresh_feed.delay("http://example.com/rss") # Async
+ <AsyncResult: 8998d0f4-da0b-4669-ba03-d5ab5ac6ad5d>
"""
@@ -135,8 +127,10 @@ def run(self, *args, **kwargs):
return inner_create_task_cls()(*args)
return inner_create_task_cls(**options)
-# The "default" loader is the default loader used by old applications.
+#: The "default" loader is the default loader used by old applications.
default_loader = os.environ.get("CELERY_LOADER") or "default"
+
+#: Global fallback app instance.
default_app = App(loader=default_loader, set_as_current=False)
if os.environ.get("CELERY_TRACE_APP"):
@@ -160,10 +154,9 @@ def app_or_default(app=None):
def app_or_default(app=None):
"""Returns the app provided or the default app if none.
- If the environment variable :envvar:`CELERY_TRACE_APP` is set,
- any time there is no active app and exception is raised. This
- is used to trace app leaks (when someone forgets to pass
- along the app instance).
+ The environment variable :envvar:`CELERY_TRACE_APP` is used to
+ trace app leaks. When enabled an exception is raised if there
+ is no active app.
"""
global _current_app
View
@@ -1,4 +1,13 @@
+"""
+celery.app.amqp
+===============
+
+AMQ related functionality.
+:copyright: (c) 2009 - 2010 by Ask Solem.
+:license: BSD, see LICENSE for more details.
+
+"""
from datetime import datetime, timedelta
from UserDict import UserDict
Oops, something went wrong.

0 comments on commit 823f45c

Please sign in to comment.