Created
December 25, 2013 17:37
-
-
Save sirn/8125185 to your computer and use it in GitHub Desktop.
Celery integration with Pyramid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .tasks import celery, configure_celery | |
# ... | |
def main(global_config, **settings): # pragma: no cover | |
""" This function returns a Pyramid WSGI application. | |
""" | |
# ... | |
configure_celery(celery, settings) | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from pyramid.paster import bootstrap | |
from app.tasks import celery, configure_celery | |
def main(argv=sys.argv): | |
if not len(argv) >= 2: | |
sys.stderr.write("Usage: %s config\n" % os.path.basename(argv[0])) | |
sys.stderr.write("Configuration file not present.\n") | |
sys.exit(1) | |
app = bootstrap(argv[1]) | |
celery_app = configure_celery(celery, app['registry'].settings) | |
celery_app.start(argv[:1] + argv[2:]) # Remove argv[1]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
setup( | |
name='app', | |
# ... | |
entry_points="""\ | |
[console_scripts] | |
pycelery = app.celery:main | |
""", | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
celery = Celery() | |
def configure_celery(_celery, settings): | |
_celery.conf.update( | |
BROKER_URL=settings['celery.broker'], | |
CELERY_RESULT_BACKEND=settings['celery.broker']) | |
return _celery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment