pulsar 0,0,0,0,5 travis-ci python

Super fast Pulsar 2.0 is coming!!

.. image:: https://pulsar.fluidily.com/assets/images/pulsar-banner-600.svg :alt: Pulsar :width: 300

|
:Badges: |license| |pyversions| |status| |pypiversion| :Master CI: |master-build|_ |coverage-master| |appveyor| :Documentation: http://quantmind.github.io/pulsar/ :Downloads: http://pypi.python.org/pypi/pulsar :Source: https://github.com/quantmind/pulsar :Stack overflow: questions tagged python-pulsar_ :Mailing list: google user group_ :Design by: Quantmind_ and Luca Sbardella_ :Platforms: Linux, OSX, Windows. Python 3.5 and above :Keywords: client, server, asynchronous, concurrency, actor, thread, process, socket, wsgi, websocket, redis, json-rpc

.. |pypiversion| image:: https://badge.fury.io/py/pulsar.svg :target: https://pypi.python.org/pypi/pulsar .. |pyversions| image:: https://img.shields.io/pypi/pyversions/pulsar.svg :target: https://pypi.python.org/pypi/pulsar .. |license| image:: https://img.shields.io/pypi/l/pulsar.svg :target: https://pypi.python.org/pypi/pulsar .. |status| image:: https://img.shields.io/pypi/status/pulsar.svg :target: https://pypi.python.org/pypi/pulsar .. |downloads| image:: https://img.shields.io/pypi/dd/pulsar.svg :target: https://pypi.python.org/pypi/pulsar .. |master-build| image:: https://travis-ci.org/quantmind/pulsar.svg?branch=master .. _master-build: http://travis-ci.org/quantmind/pulsar .. |dev-build| image:: https://travis-ci.org/quantmind/pulsar.svg?branch=dev .. _dev-build: http://travis-ci.org/quantmind/pulsar .. |coverage-master| image:: https://coveralls.io/repos/github/quantmind/pulsar/badge.svg?branch=master :target: https://coveralls.io/github/quantmind/pulsar?branch=master .. |coverage-dev| image:: https://coveralls.io/repos/github/quantmind/pulsar/badge.svg?branch=dev :target: https://coveralls.io/github/quantmind/pulsar?branch=dev .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/w2ip01j07qm161ei?svg=true :target: https://ci.appveyor.com/project/lsbardel/pulsar

An example of a web server written with pulsar which responds with “Hello World!” for every request:

.. code:: python

from pulsar.apps import wsgi

def hello(environ, start_response):
    data = b'Hello World!\n'
    response_headers = [
        ('Content-type','text/plain'),
        ('Content-Length', str(len(data)))
    ]
    start_response('200 OK', response_headers)
    return [data]


if __name__ == '__main__':
    wsgi.WSGIServer(callable=hello).start()

Pulsar’s goal is to provide an easy way to build scalable network programs. In the Hello world! web server example above, many client connections can be handled concurrently. Pulsar tells the operating system (through epoll or select) that it should be notified when a new connection is made, and then it goes to sleep.

Pulsar uses the asyncio_ module from the standard python library and it can be configured to run in multi-processing mode.

Another example of pulsar framework is the asynchronous HttpClient_:

.. code:: python

from pulsar.apps import http

async with http.HttpClient() as session:
    response1 = await session.get('https://github.com/timeline.json')
    response2 = await session.get('https://api.github.com/emojis.json')

The http client maintains connections alive (by default 15 seconds) and therefore any requests that you make within a session will automatically reuse the appropriate connection. All connections are released once the session exits the asynchronous with block.

Installing

Pulsar has no hard dependencies, install via pip::

pip install pulsar

or download the tarball from pypi_.

Applications

Pulsar design allows for a host of different asynchronous applications to be implemented in an elegant and efficient way. Out of the box it is shipped with the the following:

  • Socket servers
  • Asynchronous WSGI server_
  • HttpClient_
  • JSON-RPC_
  • Web Sockets_
  • Asynchronous Test suite_
  • Data stores_ (with async Redis client)
  • Task queue consumers_
  • Asynchronous botocore_
  • django integration_

.. _examples:

Examples

Check out the examples directory for various working applications. It includes:

  • Hello world! wsgi example
  • An Httpbin WSGI application
  • An HTTP Proxy server
  • A JSON-RPC Calculator server
  • Websocket random graph.
  • Websocket chat room.
  • The dining philosophers problem <http://en.wikipedia.org/wiki/Dining_philosophers_problem>_.
  • Twitter streaming <https://github.com/quantmind/pulsar-twitter>_

Design

Pulsar internals are based on actors primitive_. Actors are the atoms of pulsar’s concurrent computation, they do not share state between them, communication is achieved via asynchronous inter-process message passing, implemented using the standard python socket library.

Two special classes of actors are the Arbiter, used as a singleton_, and the Monitor, a manager of several actors performing similar functions. The Arbiter runs the main eventloop and it controls the life of all actors. Monitors manage group of actors performing similar functions, You can think of them as a pool of actors.

.. image:: https://pulsar.fluidily.com/assets/images/actors.png :alt: Pulsar Actors

More information about design and philosophy in the documentation.

Add-ons

Pulsar checks if some additional libraries are available at runtime, and uses them to add additional functionalities or improve performance:

  • greenlet: required by the pulsar.apps.greenio module and useful for developing implicit asynchronous applications
  • uvloop_: if available it is possible to use it as the default event loop for actors by passing --io uv in the command line (or event_loop="uv" in the config file)
  • http-parser_: if available, the default HttpParser for both client and server is replaced by the C implementation in this package (about three times faster than pulsar python version)
  • setproctitle_: if installed, pulsar can use it to change the processes names of the running application
  • psutil_: if installed, a system key is available in the dictionary returned by Actor info method
  • python-certifi: The HttpClient will attempt to use certificates from certifi if it is present on the system
  • ujson_: if installed it is used instead of the native json module
  • unidecode_: to enhance the slugify function

Running Tests

Pulsar test suite uses the pulsar test application. To run tests::

python setup.py test

For options and help type::

python setup.py test --help

flake8_ check (requires flake8 package)::

flake8

.. _contributing:

Contributing

Development of pulsar_ happens at Github. We very much welcome your contribution of course. To do so, simply follow these guidelines:

  • Fork pulsar_ on github
  • Create a topic branch git checkout -b my_branch
  • Push to your branch git push origin my_branch
  • Create an issue at https://github.com/quantmind/pulsar/issues with pull request for the dev branch.
  • Alternatively, if you need to report a bug or an unexpected behaviour, make sure to include a mcve_ in your issue.

A good pull request should:

  • Cover one bug fix or new feature only
  • Include tests to cover the new code (inside the tests directory)
  • Preferably have one commit only (you can use rebase_ to combine several commits into one)
  • Make sure flake8 tests pass

.. _license:

License

This software is licensed under the BSD_ 3-clause License. See the LICENSE file in the top distribution directory for the full license text.

.. _asyncio: https://docs.python.org/3/library/asyncio.html .. _multiprocessing: http://docs.python.org/library/multiprocessing.html .. _actors primitive: http://en.wikipedia.org/wiki/Actor_model .. _setproctitle: http://code.google.com/p/py-setproctitle/ .. _psutil: https://github.com/giampaolo/psutil .. _pypi: http://pypi.python.org/pypi/pulsar .. _BSD: http://opensource.org/licenses/BSD-3-Clause .. _pulsar: https://github.com/quantmind/pulsar .. _singleton: http://en.wikipedia.org/wiki/Singleton_pattern .. _cython: http://cython.org/ .. _google user group: https://groups.google.com/forum/?fromgroups#!forum/python-pulsar .. _flake8: https://pypi.python.org/pypi/flake8 .. _ujson: https://pypi.python.org/pypi/ujson .. _rebase: https://help.github.com/articles/about-git-rebase .. _unidecode: https://pypi.python.org/pypi/Unidecode .. _Luca Sbardella: http://lucasbardella.com .. _Quantmind: http://quantmind.com .. _JSON-RPC: http://www.jsonrpc.org/ .. _mcve: http://stackoverflow.com/help/mcve .. _python-certifi: https://certifi.io .. _greenlet: http://greenlet.readthedocs.io/ .. _pulsar.apps.greenio: https://github.com/quantmind/pulsar/tree/master/pulsar/apps/greenio .. _pulsar.apps.pulse: https://github.com/quantmind/pulsar/tree/master/pulsar/apps/pulse .. _HttpClient: http://quantmind.github.io/pulsar/apps/http.html .. _Data stores: http://quantmind.github.io/pulsar/apps/data/index.html .. _Task queue consumers: https://github.com/quantmind/pulsar-queue .. _Asynchronous botocore: https://github.com/quantmind/pulsar-cloud .. _django integration: https://github.com/quantmind/pulsar-django .. _python-pulsar: http://stackoverflow.com/questions/tagged/python-pulsar .. _Web Sockets: http://quantmind.github.io/pulsar/apps/websockets.html .. _uvloop: https://github.com/MagicStack/uvloop .. _http-parser: https://github.com/benoitc/http-parser .. _Asynchronous WSGI server: http://quantmind.github.io/pulsar/apps/wsgi/index.html .. _Asynchronous Test suite: http://quantmind.github.io/pulsar/apps/test.html

Related Repositories

pulsar

pulsar

Super fast Pulsar 2.0 is coming!! ...

pulsar

pulsar

Pulsar - distributed pub-sub messaging system ...

pulsar

pulsar

Fibers, Channels and Actors for Clojure ...

plugin.video.pulsar

plugin.video.pulsar

Pulsar addon for XBMC/Kodi ...

xbmctorrent

xbmctorrent

Torrent streaming for XBMC - This project has been replaced by Pulsar ...


Top Contributors

lsbardel msornay artemmus wilddom axisofentropy etataurov pvanderlinden remcoder robgil felippemr bright-pan DavidJFelix keis eventh cyberj mbikovitsky Pastafarianist sekrause dhutty

Releases

-   1.4.1 zip tar
-   1.4.0 zip tar
-   1.3.6 zip tar
-   1.3.5 zip tar
-   1.3.4 zip tar
-   1.3.3 zip tar
-   1.3.2 zip tar
-   1.3.1 zip tar
-   1.3.0 zip tar
-   1.2.0 zip tar
-   1.1.3 zip tar
-   1.1.2 zip tar
-   1.1.1 zip tar
-   1.0.7 zip tar
-   1.0.6 zip tar
-   1.0.5 zip tar
-   1.0.3 zip tar
-   1.0.2 zip tar
-   1.0.1 zip tar
-   1.0.0 zip tar
-   0.9.1 zip tar
-   0.9.0 zip tar
-   0.8.4 zip tar
-   0.8.3 zip tar
-   0.8.2 zip tar
-   0.8.1 zip tar
-   0.8.0 zip tar
-   0.7.4 zip tar
-   0.7.3 zip tar
-   0.6.0 zip tar