Documentation for pulsar 0.9.2. For development docs, go here.

Django Application

The pulsar.apps.pulse module is a django application for running a django web site with pulsar. Add it to the list of your INSTALLED_APPS:

INSTALLED_APPS = (
    ...,
    'pulsar.apps.pulse',
    ...
)

and run the site via the pulse command:

python manage.py pulse

Check the django chat example for a django chat application served by a multiprocessing pulsar server.

By default, the pulse command creates a Wsgi middleware which runs the django application in a separate thread of execution from the main event loop. This is a standard programming pattern when using asyncio with blocking functions. To control the number of thread workers in the event loop executor (which is a pool of threads) one uses the thread-workers option. For example, the following command:

python manage.py pulse -w 4 --thread-workers 20

will run four process based actors, each with an executor with up to 20 threads.

Greenlets

It is possible to run django in fully asynchronous mode, i.e. without running the middleware in the event loop executor. Currently, this is available when using PostgreSql backend only, and it requires the greenlet library.

To run django using greenlet support:

python manage.py pulse -w 4 --greenlet

By default it will run the django middleware on a pool of 100 greenlets (and therefore approximately 100 separate database connections per actor). To adjust this number:

python manage.py pulse -w 4 --greenlet 200

Wsgi middleware

class pulsar.apps.pulse.Wsgi[source]

The Wsgi middleware used by the django pulse command

setup(environ=None)[source]

Set up the WsgiHandler the first time this middleware is accessed.



Table Of Contents

Previous topic

Asynchronous HTTP client

Next topic

Greenlet Support

This Page