Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Asynchronous Django

Badges:

license pyversions status pypiversion

CI:

circleci coverage

Documentation:

https://github.com/quantmind/pulsar-django

Downloads:

http://pypi.python.org/pypi/pulsar-django

Source:

https://github.com/quantmind/pulsar-django

Keywords:

asynchronous, django, wsgi, websocket, redis

The 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 = (
    ...,
    'pulse',
    ...
)

and run the site via the pulse command:

python manage.py pulse

Check the django chat example djchat 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

Django Chat Example

This is a web chat application which illustrates how to run a django site with pulsar and how to include pulsar asynchronous request middleware into django.

To run:

python manage.py pulse

If running for the first time, issue the:

python manage.py migrate

command and create the super user:

python manage.py createsuperuser

Message and data backend

By default, messages from connected (websocket) clients are synchronised via the pulsar data store which starts when the django site starts.

It is possible to specify a different data store via the data-store option. For example, it is possible to use redis as an alternative data store by issuing the following start up command:

python manage.py pulse --data-store redis://127.0.0.1:6379/3

Metadata

Release files for pulsar-django 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pulsar-django 0.3.0
File Size Uploaded
pulsar-django-0.3.0.tar.gz 10.1 kB Details

Release files / pulsar-django-0.3.0.tar.gz

Download URL pulsar-django-0.3.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
02935b75c05e6ffc201344ab770b1c70cafb2d4e3d4e0e31edf370873177a9ca
BLAKE2b-256 checksum
How to use checksums
149fefe190c6cbb63fb72d0729cb89161b5fab80e459429744d1c991756e13b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page