Package: pulsar
Badges:CI:Documentation:https://docs.pulsarweb.orgDownloads:http://pypi.python.org/pypi/pulsarSource:https://github.com/quantmind/pulsarBenchmarks:https://bench.pulsarweb.org/Chat channel:Riot.im roomMailing list:google user groupStack overflow:questions taggedpython-pulsarDesign by:QuantmindandLuca SbardellaPlatforms:Linux, OSX, Windows. Python 3.5 and aboveKeywords:python, asyncio, multiprocessing, client/server, asynchronous, concurrency, actor, thread, process, socket, wsgi, websocket, redis, json-rpcAn example of a web server written withpulsarwhich responds with
“Hello World!” for every request:frompulsar.appsimportwsgidefhello(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 theHello 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 theasynciomodule from the standard python
library and it can be configured to run in multi-processing mode.Another example of pulsar framework is the asynchronousHttpClient:frompulsar.appsimporthttpasyncwithhttp.HttpClient()assession:response1=awaitsession.get('https://github.com/timeline.json')response2=awaitsession.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
asynchronouswithblock.InstallingPulsar has onehard dependency:multidictinstall via pip:pip install pulsaror download the tarball frompypi.To speedup pulsar by a factor of 2 or more thesesoft dependenciesare recommendedhttptoolsuvloopApplicationsPulsar 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 serversAsynchronous WSGI serverHttpClientJSON-RPCWeb SocketsAsynchronous Test suiteData stores(with async Redis client)Task queue consumersAsynchronous botocoredjango integrationExamplesCheck out theexamplesdirectory for various working applications.
It includes:Hello world! wsgi exampleAn Httpbin WSGI applicationAn HTTP Proxy serverA JSON-RPC Calculator serverWebsocket random graph.Websocket chat room.Thedining philosophers problem.Twitter streamingDesignPulsar internals are based onactors primitive.Actorsare theatomsof 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 theArbiter, used as asingleton,
and theMonitor, 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.More information about design and philosophy in the documentation.Add-onsPulsar checks if some additional libraries are available at runtime, and
uses them to add additional functionalities or improve performance:greenlet: required by thepulsar.apps.greeniomodule and useful for
developing implicit asynchronous applicationsuvloop: if available it is possible to use it as the default event loop
for actors by passing--iouvin the command line (orevent_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 packagesetproctitle: if installed, pulsar can use it to change the processes names
of the running applicationpsutil: if installed, asystemkey is available in the dictionary
returned by Actor info methodpython-certifi: TheHttpClientwill attempt to use certificates from
certifi if it is present on the systemujson: if installed it is used instead of the nativejsonmoduleunidecode: to enhance theslugifyfunctionRunning TestsPulsar test suite uses the pulsar test application. To run tests:python setup.py testFor options and help type:python setup.py test --helpflake8check (requires flake8 package):flake8ContributingDevelopment ofpulsarhappens at Github. We very much welcome your contribution
of course. To do so, simply follow these guidelines:Forkpulsaron githubCreate a topic branchgit checkout-bmy_branchPush to your branchgit push origin my_branchCreate an issue athttps://github.com/quantmind/pulsar/issueswith
pull request for thedev branch.Alternatively, if you need to report a bug or an unexpected behaviour, make sure
to include amcvein your issue.A goodpullrequest should:Cover one bug fix or new feature onlyInclude tests to cover the new code (inside thetestsdirectory)Preferably have one commit only (you can userebaseto combine several
commits into one)Make sureflake8tests passLicenseThis software is licensed under theBSD3-clause License. See the LICENSE
file in the top distribution directory for the full license text.