This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Celery integration with CubicWeb

Getting Started

Enable the ‘celery’ cube in your myapp cubicweb instance:

$ cubicweb-ctl shell myapp
entering the migration python shell
just type migration commands or arbitrary python code and type ENTER to execute it
type "exit" or Ctrl-D to quit the shell and resume operation
>>> add_cube('celery')
>>> ^D

If needed, configure the broker_url in all-in-one.conf. By default, and only when using a postgresql database, the trunk transport will be used for the broker; make sure it is installed.

Write a task:

from cubicweb_celery import app

@app.cwtask
def ping(self):
    return 'pong'

@app.cwtask
def users(self):
    return [str(x[0]) for x in self.cw_cnx.execute('String L WHERE U login L')]

or as a class:

from cubicweb_celery import app

class MyTask(app.Task):
    need_cnx = True  # if false (the default), self.cw_cnx will not be set
                     # before running the task

    def run(self):
        self.cw_cnx.execute('Any X WHERE ...')

Note

In order to have the task automatically available by the celery worker, you must ensure that it is in a Python file that is automatically loaded by CubicWeb, best candidate being the sobjects module of a cube (see the CubicWeb’s regitry documentation).

Then start a celery worker:

celery -A cubicweb_celery -i INSTANCE_NAME worker [ --beat ]

Then you can make the worker execute a task by calling it, eg. from an Operation. You may also run a task from a cubicweb-ctl shell:

$ cubicweb-ctl shell myapp
>>> from cubes.myapp.sobjects import ping, users
>>> print ping.delay().wait()
'pong'
>>> print users.delay().wait()
['anon', 'admin']
Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cubicweb-celery-0.2.0.tar.gz (5.4 kB) Copy SHA256 Checksum SHA256 Source Oct 11, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting