All Projects → quantmind → Pulsar

quantmind / Pulsar

Licence: bsd-3-clause
Event driven concurrent framework for Python

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
shell
77523 projects
c
50402 projects - #5 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to Pulsar

Gunicorn
gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.
Stars: ✭ 8,001 (+328.55%)
Mutual labels:  wsgi, http-server
Rpc.py
A fast and powerful RPC framework based on ASGI/WSGI.
Stars: ✭ 98 (-94.75%)
Mutual labels:  rpc, wsgi
Aiomultiprocess
Take a modern Python codebase to the next level of performance.
Stars: ✭ 1,070 (-42.69%)
Mutual labels:  asyncio, multiprocessing
Httpserver
Python 3 implementation of an HTTP server
Stars: ✭ 5 (-99.73%)
Mutual labels:  asyncio, http-server
Cheroot
Cheroot is the high-performance, pure-Python HTTP server used by CherryPy. Docs -->
Stars: ✭ 128 (-93.14%)
Mutual labels:  wsgi, http-server
Chili
Chili: HTTP Served Hot
Stars: ✭ 7 (-99.63%)
Mutual labels:  asyncio, http-server
Tractor
structured concurrent, Python parallelism
Stars: ✭ 88 (-95.29%)
Mutual labels:  rpc, multiprocessing
Hydra
后端一站式微服务框架,提供API、web、websocket,RPC、任务调度、消息消费服务器
Stars: ✭ 407 (-78.2%)
Mutual labels:  rpc, http-server
Purerpc
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio
Stars: ✭ 125 (-93.3%)
Mutual labels:  rpc, asyncio
Netius
Readable, simple and fast asynchronous non-blocking network apps
Stars: ✭ 114 (-93.89%)
Mutual labels:  asyncio, wsgi
Gevent
Coroutine-based concurrency library for Python
Stars: ✭ 5,656 (+202.95%)
Mutual labels:  asyncio, greenlet
Aiohttp
Asynchronous HTTP client/server framework for asyncio and Python
Stars: ✭ 11,972 (+541.24%)
Mutual labels:  asyncio, http-server
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+190.31%)
Mutual labels:  rpc, http-server
Quart
Official mirror of https://gitlab.com/pgjones/quart
Stars: ✭ 872 (-53.29%)
Mutual labels:  asyncio, http-server
Aioprocessing
A Python 3.4+ library that integrates the multiprocessing module with asyncio
Stars: ✭ 438 (-76.54%)
Mutual labels:  asyncio, multiprocessing
Pytask Io
Python Async Task Queue
Stars: ✭ 81 (-95.66%)
Mutual labels:  asyncio, wsgi
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+81.68%)
Mutual labels:  rpc, http-server
Uvicorn
The lightning-fast ASGI server. 🦄
Stars: ✭ 4,676 (+150.46%)
Mutual labels:  asyncio, http-server
Zanphp
PHP开发面向C10K+的高并发SOA服务 和RPC服务首选框架
Stars: ✭ 1,451 (-22.28%)
Mutual labels:  rpc, asyncio
Python Concurrency
Code examples from my toptal engineering blog article
Stars: ✭ 131 (-92.98%)
Mutual labels:  asyncio, multiprocessing

Pulsar



Badges:license pyversions status pypiversion contributors
CI:circleci coverage appveyor travis docs
Documentation:https://docs.pulsarweb.org
Downloads:http://pypi.python.org/pypi/pulsar
Source:https://github.com/quantmind/pulsar
Benchmarks:https://bench.pulsarweb.org/
Chat channel:Riot.im room
Mailing list:google user group
Stack overflow:questions tagged python-pulsar
Design by:Quantmind and Luca Sbardella
Platforms:Linux, OSX, Windows. Python 3.5 and above
Keywords:python, asyncio, multiprocessing, client/server, asynchronous, concurrency, actor, thread, process, socket, wsgi, websocket, redis, json-rpc

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

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:

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 one hard dependency:

install via pip:

pip install pulsar

or download the tarball from pypi.

To speedup pulsar by a factor of 2 or more these soft dependencies are recommended

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:

Examples

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

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.

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)
  • httptools: if available, the default Http Parser for both client and server is replaced by the C implementation in this package
  • 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

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].