Pysher
pysherplus is a python module for handling pusher websockets. It is based on @deepbrok's fork of @ekulyk's PythonPusherClient.
You can check out the deepbrook fork here. Deepbrook's code was in maintenance mode, and I wanted a more actively maintained project with a few bug fixes to use in a project.
New features
- Subscription status of channels is automatically maintained and can be setup before connection.
- Authorization support for known secret, url based (such as Laravel), and even custom websocket authentication.
- Better support for custom URLs using the PusherHost class.
Installation
Install via pip pip install pysherplus.
This module depends on websocket-client module available from: http://github.com/websocket-client/websocket-client
Example
Example of using this pusher client to consume websockets:
import sys
import time
from pysherplus.pusher import Pusher
# Add a logging handler so we can see the raw communication data
import logging
root = logging.getLogger()
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
root.addHandler(ch)
app_key = "my_pusher_app_key"
pusher = Pusher(app_key)
def my_func(event, data):
print("processing Event:", event)
print("processing Data:", data)
pusher["my_channel"]["my_event"].register(my_func)
pusher.connect()
while True:
# Do other things in the meantime here...
time.sleep(1)
Performance
PysherPlus relies on websocket-client (websocket-client on pyPI, websocket import in code), which by default does utf8 validation in pure python. This is somewhat cpu hungry for lot's of messages (100's of KB/s or more). To optimize this validation consider installing the wsaccel module from pyPI to let websocket-client use C-compiled utf5 validation methods (websocket does this automatically once wsaccel is present and importable).
Thanks
Huge thanks to @deepbrook for forking the original repo and by proxy, thank you to all of the people who they thanked.
Copyright
MTI License - See LICENSE for details.
Changelog
Version 2.0.0
Forked and refactored @deepbrook's code and republished under PysherPlus name.
For previous versions, see the original repo's changelog
Metadata
Release files for PysherPlus 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PysherPlus-2.0.1.tar.gz | 9.1 kB | Without provenance | Details for PysherPlus-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PysherPlus-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for PysherPlus-2.0.1-py3-none-any.whl |
Total release size: 19.4 kB
Release files / PysherPlus-2.0.1.tar.gz
| Download URL | PysherPlus-2.0.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a314514de90f4012c0c9c1d2bd3234767324711cacde5d530eae870ed290066e
|
|
BLAKE2b-256 checksum How to use checksums |
8f9cd5fccd638db81b714f4befd73a6cf51e202f60aa90fad367c73dff2446ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Release files / PysherPlus-2.0.1-py3-none-any.whl
| Download URL | PysherPlus-2.0.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8aebeaca27a07b83d672257fa05435e6a49679f84d73aaee5321e2e442c138b0
|
|
BLAKE2b-256 checksum How to use checksums |
b8363172e4056fec10f7dadf9d17e64ed054b5d9810de73ea0e1456eef501356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
|
Security for PysherPlus 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.