Skip to main content

Asyncio Pusher Channels Client

Project description


pysherasync is a python module for handling Pusher Channels. It is based on @ekulyk's PythonPusherClient and @nlsdfnbch Pysher. This is a re-implementation of the project to use more efficient asynchronous logic and more efficient websockets. A key difference is the dropped support for pre-3.5 Python versions.

This is also currently a very minimalistic implementation and may be missing some components, please submit an issue and let me know if you run into any problems.


Simply clone the project and run python install - or install via pip pip install pysherasync.

This module depends on websockets module available from:


Example of using this pusher client to consume websockets:

import pysherasync

async def bitstamp_ob_subscription(loop):
    global loop 
    # This is your app key, currently set to 
    appkey = "de504dc5763aeef9ff52"
    # Create an instance of PusherAsyncClient and pass it the appkey 
    pusherclient = pysherasync.PusherAsyncClient(appkey)
    # Connect to websocket 
    pushersocket = await pusherclient.connect()
    # Subscribe to channel 
    status = await pusherclient.subscribe(channel_name='order_book')
    print("Subscription Status: %s"%(status))
    while True:
        ## This is because re-connection logic is not implemented yet
        if not
            # on disconnections, reconnect
            print("Connection reconnecting")
            # re-connect
            pushersocket = await pusherclient.connect()
            # re-subscribe 
            status = await pusherclient.subscribe(channel_name='order_book')
            print("Subscription Status: %s"%(status))
            # wait for msg
            msg = await asyncio.wait_for(pushersocket.recv(), 5)
            # parse to json 
            msg = json.loads(msg)
            # print the msg 
            if msg:
        except asyncio.TimeoutError:
            print("asyncio timeout while waiting for ws msg")
        except Exception as e:

 if __name__ == "__main__":
    loop = asyncio.new_event_loop()


PysherAsync relies on websockets which is one of the most efficient implementations on python.


A big thanks to @ekulyk for developing the PythonPusherClient library.

A big thanks to @nlsdfnbch for developing the Pysher library.

A big thanks to @aaugustin for developing the WebSockets library.


MTI License - See LICENSE for details.


Version 0.2


  • Bug fix for disconnect, added missing await

Version 0.1


  • First Working Version

Project details

Download files

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

Source Distribution

pysherasync-0.2.tar.gz (4.8 kB view hashes)

Uploaded source

Built Distribution

pysherasync-0.2-py3-none-any.whl (5.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page