Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Python asynch distributed and scalable Queue Services

Project description

PyAsynch

PyAsynch is a package to create distributed Python Services through RabbitMQ.

The services talk each other through a common RabbitMQ queue and expose the service also as HTTP Tornado Server

How to use it

pip install pyasynch

or

pip3 install pyasynch

or just clone the git repo.

Create your custom node


from pyasynch.node import Node

class MyNode(Node):

    def mymethod(self,arg1,arg2,**kwargs):
        return {'myproperty':'myvalue'}

    def mysecondmethod(self,myproperty,**kwargs):
        return {}   

Create the configuration file (e.g. myconfig.json)

{
  "endpoint": {
    "amqp": "amqp://guest:guest@127.0.0.1:5672/pyasynch",
    "id": "myendpoint",
    "threaded": false
  }
}

Create the routing file (e.g. myroutes.json)

{
 "routes": {
    "pyasynch://myendpoint/mynode/mymethod" : ["pyasynch://myendpoint/mynode/mysecondmethod"],
}    

Create the main (e.g. main.py) runner and register the node

# IMPORTS
from pyasynch.environment import Environment

env = Environment()
env.register_node('mynode',MyNode(env.endpoint))

try:
    env.run()
except KeyboardInterrupt:
    env.stop()

Everything is ready, now you can run the endpoint service (check if RabbitMQ is running properly)

python3 main.py -c myconfig.json -r myroutes.json -p 8081

You can replicate nodes and endpoint logic in a scalable way.

You can then perform JSON get or POST to the endpoint: http://127.0.0.1:8081/mynode/mymethod

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyAsynch, version 1.2.2
Filename, size File type Python version Upload date Hashes
Filename, size PyAsynch-1.2.2-py3-none-any.whl (12.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page