Coder Social home page Coder Social logo

pombredanne / pulsar-django Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quantmind/pulsar-django

0.0 1.0 0.0 24 KB

django pulse application

License: BSD 3-Clause "New" or "Revised" License

Python 81.21% CSS 1.91% JavaScript 7.89% HTML 9.00%

pulsar-django's Introduction

Asynchronous Django

Badges:license pyversions status pypiversion
Master CI:master-build coverage-master
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 syncdb

command and create the super user.

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

pulsar-django's People

Contributors

lsbardel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.