PysherAsync
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.
Installation
Simply clone the project and run python setup.py install - or install via pip pip install pysherasync.
This module depends on websockets module available from: https://github.com/aaugustin/websockets
Example
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 https://www.bitstamp.net/websocket/
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 pushersocket.open:
# 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))
try:
# wait for msg
msg = await asyncio.wait_for(pushersocket.recv(), 5)
# parse to json
msg = json.loads(msg)
# print the msg
if msg:
print(msg)
except asyncio.TimeoutError:
print("asyncio timeout while waiting for ws msg")
except Exception as e:
print(e)
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(bitstamp_ob_subscription(loop))
loop.close()
Performance
PysherAsync relies on websockets which is one of the most efficient implementations on python.
Thanks
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.
Copyright
MTI License - See LICENSE for details.
Changelog
Version 0.2
Fix
- Bug fix for disconnect, added missing await
Version 0.1
New
- First Working Version
Metadata
Release files for pysherasync 0.2
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 | |
|---|---|---|---|---|
| pysherasync-0.2.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysherasync-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / pysherasync-0.2.tar.gz
| Download URL | pysherasync-0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5061ab45e952eb75ab8700c1a306347414e4c9b5c6f5587b22f09677c3663542
|
|
BLAKE2b-256 checksum How to use checksums |
1f400c1391951cf28a5b65b4dc9372b1862360693317bad74daa1ea73bb010e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / pysherasync-0.2-py3-none-any.whl
| Download URL | pysherasync-0.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7580a739f470b496ad6442118844ecd3e63db920d6f5bfef4b24c73bfabdaead
|
|
BLAKE2b-256 checksum How to use checksums |
ba8d7fbc7a565d36730f3a00fe0296e4a365c043d639f6b3ee95a3e37de2d1f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for pysherasync 0.2
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.