Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use the defauly celery app.

This requires (what will be) celery 2.6 or later.
  • Loading branch information...
commit a963eaa0bf7fe9aedb85f4639fc0d0fbdaa84538 1 parent b5c384f
@wichert wichert authored
View
8 README.md
@@ -10,8 +10,10 @@ or by calling config.include('pyramid_celery').
Now you can either use class based:
``` python
-from pyramid_celery import Task
+from celery.task import task
+from celery.task import Task
+@task
class AddTask(Task):
def run(self, x, y):
print x+y
@@ -20,9 +22,9 @@ class AddTask(Task):
or decorator based:
``` python
-from pyramid_celery import celery
+from celery.task import task
-@celery.task
+@task
def add(x, y):
print x+y
```
View
31 pyramid_celery/__init__.py
@@ -1,31 +1,6 @@
-from celery import Celery
+from celery.app import default_app
-from celery.app import App
-
-from celery.loaders import default as _default
-from celery.utils import get_full_cls_name
-
-celery = Celery()
-Task = celery.create_task_cls()
def includeme(config):
- celery.config_from_object(config.registry.settings)
- celery.config = config
-
-class PyramidLoader(_default.Loader):
-
- def read_configuration(self):
- config = self.app.env['registry'].settings
- settings = self.setup_settings(config)
- self.configured = True
- return settings
-
-class Celery(App):
- loader_cls = get_full_cls_name(PyramidLoader)
-
- def __init__(self, env=None, *args, **kwargs):
- self.env = env
- super(Celery, self).__init__(*args, **kwargs)
-
- def __reduce_args__(self):
- return (self.env, ) + super(Celery, self).__reduce_args__()
+ default_app.config_from_object(config.registry.settings)
+ default_app.config = config
View
4 pyramid_celery/celeryd.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
import argparse
+from celery.app import default_app
from celery.bin.celeryd import WorkerCommand
from pyramid.paster import bootstrap
-from pyramid_celery import Celery
def main(): # pragma: no cover
@@ -11,7 +11,7 @@ def main(): # pragma: no cover
help='Configuration file (and optionally section)')
options = parser.parse_args()
env = bootstrap(options.config)
- worker = WorkerCommand(app=Celery(env))
+ worker = WorkerCommand(app=default_app)
worker.run()
Please sign in to comment.
Something went wrong with that request. Please try again.