Skip to main content

An asynchronous Pusher client library

Project description

asyncpusher is an asynchronous python client library for Pusher

Features

  • Uses well-maintained aiohttp's websocket library
  • Reliable connection
  • Auto handles reconnection
  • Asynchronous
  • Fast
  • Supports Pusher Channels protocol 7
  • Support presence and private channels

Install

$ python3 -m pip install asyncpusher

Usage

import asyncio
import logging
import sys

from asyncpusher.channel import Channel
from asyncpusher.pusher import Pusher

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)


async def handle_event(data):
    logging.info(f"{market} {data}")


async def main():
    loop = asyncio.get_running_loop()

    pusher = Pusher("<PUSHER_APP_KEY>", loop=loop)
    pusher.channels[channel_name] = channel
    await pusher.connect()
    channel_name = "<CHANNEL_NAME>"
    channel = await pusher.subscribe(channel_name)
    channel.bind("diff", handle_event)
    await asyncio.sleep(5)
    await pusher.unsubscribe(channel_name)
    await asyncio.sleep(1)
    await pusher.disconnect()


asyncio.run(main())

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

asyncpusher-0.2.0.tar.gz (37.2 kB view hashes)

Uploaded Source

Built Distribution

asyncpusher-0.2.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

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