PuSu Engine client for Python
Client for using the PuSu Engine server from Python. Probably much better suitable for sending than receiving, but both should work.
Threaded example
If you want immediate delivery and are ok with your callbacks getting called from another thread, you can use the threaded client.
from pypusu.threaded import PuSuClient
from time import sleep
if __name__ == "__main__":
c = PuSuClient("ws://127.0.0.1:55000")
count = 0
def listener(msg):
global count
count += 1
c.authorize("foo")
c.subscribe("channel.1", listener)
c.publish("channel.1", {"foo": "bar"})
sleep(30)
print(count)
Polling example
If your callbacks getting called from another thread is an issue, you can use the polling client. Internally it still uses threads, but it will not deliver the messages to your callbacks until you call poll().
from pypusu.polling import PuSuClient
from time import sleep
if __name__ == "__main__":
c = PuSuClient("ws://127.0.0.1:55000")
count = 0
def listener(msg):
global count
count += 1
c.authorize("foo")
c.subscribe("channel.1", listener)
c.publish("channel.1", {"foo": "bar"})
for i in range(0, 30):
sleep(1)
c.poll()
print(count)
Dependencies
Not quite sure how to deal with dependencies yet, so for now you’ll have to install them separately.
Both threaded and polling client need the following in your requirements.txt:
ws4py==0.3.5 wsaccel==0.6.2
Or you can try:
pip install ws4py wsaccel
License
Short version: MIT + New BSD.
Long version: Read the LICENSE.md -file.
Uploading to PyPi
You can’t really do that without the appropriate username + password information, but I’m saving this here because I’ll just forget.
python setup.py sdist upload -r pypitest python setup.py sdist upload -r pypi
Metadata
Release files for pypusu 1.0.6
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 |
|---|---|---|---|---|
| pypusu-1.0.6.tar.gz | 6.4 kB | Without provenance | Details for pypusu-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypusu-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for pypusu-1.0.6-py3-none-any.whl |
Total release size: 14.1 kB
Release files / pypusu-1.0.6.tar.gz
| Download URL | pypusu-1.0.6.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf649012cf4830f2fe981ff07e40fdbdb1f66b92e29ac9ede9415ce3860303d5
|
|
BLAKE2b-256 checksum How to use checksums |
95a32dc2ef22b406a943fbecee78ed295fa0ec4405ba9e647ec16043b594ab7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|
Release files / pypusu-1.0.6-py3-none-any.whl
| Download URL | pypusu-1.0.6-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25cb36b4131ba1aa9979f2b7abdb8d46256aefa661db49648bc3b39dff1fba1e
|
|
BLAKE2b-256 checksum How to use checksums |
124b42d4057643d6b40418163c51ef3d9b3a6c0f1e228278619d8ba58b24ff89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|
Security for pypusu 1.0.6
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.