Registry / http-networking / pysher

pysher

JSON →
library1.0.8pypypi✓ verified 87d ago

Pysher is a Python module for handling Pusher websockets, based on Erik Kulyk's PythonPusherClient. It provides client-side functionality to connect to Pusher channels, subscribe to events, and bind callbacks to handle real-time data. The project is currently in maintenance mode, welcoming PRs for fixes, updates, and features, with releases occurring periodically for merged improvements.

pip install pysher
INSTALL
IMPORT
SIG · PYSHER
P
pysher
http-networkingpythonv1.0.8
Install
3.1s avg
Import
608ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.637s · 23.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.1s · import 0.580s · 24MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Pusher
import pysher pusher = pysher.Pusher(...)

This quickstart demonstrates how to connect to Pusher, subscribe to a channel, and bind a callback function to an event. It includes basic logging to observe the connection process and uses environment variables for the Pusher App Key for secure credentials handling.

import pysher import os import time import logging # Configure logging to see Pysher's internal communication root = logging.getLogger() root.setLevel(logging.INFO) ch = logging.StreamHandler() root.addHandler(ch) # Replace with your actual Pusher App Key and Cluster APP_KEY = os.environ.get('PUSHER_APP_KEY', 'your_app_key') CLUSTER = os.environ.get('PUSHER_CLUSTER', 'mt1') # e.g., 'mt1', 'eu', 'ap1' if APP_KEY == 'your_app_key': print("WARNING: Please set PUSHER_APP_KEY environment variable or replace 'your_app_key' in the code.") def my_func(*args, **kwargs): """Callback function to process messages from a subscribed event.""" print(f"Processing Args: {args}") print(f"Processing Kwargs: {kwargs}") def connect_handler(data): """Callback function when connection is established.""" print(f"Connected to Pusher! Connection data: {data}") # Subscribe to a channel after successful connection channel = pusher.subscribe('my-channel') # Bind a callback to a specific event on that channel channel.bind('my-event', my_func) print("Subscribed to 'my-channel' and bound 'my-event'.") # Initialize Pusher client pusher = pysher.Pusher(APP_KEY, cluster=CLUSTER) # Bind the connect handler to the 'pusher:connection_established' event pusher.connection.bind('pusher:connection_established', connect_handler) # Connect to Pusher print("Connecting to Pusher...") pusher.connect() try: while True: # Keep the main thread alive to allow websocket client to run time.sleep(1) except KeyboardInterrupt: print("\nDisconnecting Pysher.") pusher.disconnect() print("Disconnected.")
Debug
Known issues
breakingPrior to v1.0.7, callback functions bound to events or connection binds might have received an incorrect number of arguments. Version 1.0.7 fixed this to match the expected argument signature, which could break existing code that relied on the old, incorrect argument count for `my_func(*args, **kwargs)` or similar callbacks.
fix
Review all callback functions bound to Pusher events or connection lifecycle events (e.g., `pusher:connection_established`) and adjust their signatures to correctly handle the arguments passed by Pysher 1.0.7+.
affects: <1.0.7
gotchaPysher has specific compatibility requirements with its `websocket-client` dependency. `websocket-client==0.49` is explicitly excluded in `setup.py`, and issues have been reported with `websocket-client==0.58.0` and `Pysher 1.0.6`. Always refer to the `install_requires` in `setup.py` or the official GitHub README for the exact compatible versions.
fix
Ensure your `websocket-client` version adheres to Pysher's `install_requires` specifications. If issues arise, try downgrading or upgrading `websocket-client` to a known compatible version.
affects: All versions
gotchaPysher dropped support for Python versions prior to 3.5. Attempting to use Pysher on older Python 3 releases (e.g., 3.4 or 2.x) will result in compatibility errors.
fix
Ensure your project is running on Python 3.5 or newer.
affects: All versions
gotchaThe Pysher library is explicitly stated to be in 'maintenance mode'. This implies that while bug fixes and contributions (PRs) are welcome and released, active development of new features or rapid updates should not be expected.
fix
Set realistic expectations for new features and be prepared to contribute fixes or features via pull requests if needed.
affects: All versions
gotchaFor optimal performance, especially when handling high volumes of messages, it is recommended to install the `wsaccel` package. This allows the underlying `websocket-client` to utilize C-compiled UTF-8 validation methods, which are significantly more CPU-efficient than the default pure Python implementation.
fix
Install `wsaccel` alongside Pysher: `pip install pysher wsaccel`.
affects: All versions
Upgrade
Version history
1.0.8latest on PyPI · released Oct 10, 2022
Audit
Dependencies
websocket-clientrequiredCore dependency for websocket communication. Specific version constraints apply.
requestsrequiredUsed for HTTP requests, likely for authentication or initial connection setup.
wsacceloptionalOptional dependency to improve websocket-client performance by enabling C-compiled UTF-8 validation.
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
pysher — pip install pysher · libregistry