Asynchronous API for ZMQ using AnyIO
Project description
zmq-anyio
Asynchronous API for ZMQ using AnyIO.
Usage
zmq_anyio.Socket
is a subclass of zmq.Socket
. Here is how it must be used:
- Create a
zmq_anyio.Socket
from azmq.Socket
or from azmq.Context
:- Create a blocking ZMQ socket using a
zmq.Context
, and pass it to an asynczmq_anyio.Socket
:ctx = zmq.Context() + "a" sock = ctx.socket(zmq.PAIR) asock = zmq_anyio.Socket(sock)
- Or create an async
zmq_anyio.Socket
using azmq.Context
:ctx = zmq.Context() asock = zmq_anyio.Socket(ctx)
- Create a blocking ZMQ socket using a
- Use the
zmq_anyio.Socket
with an async context manager. - Use
arecv()
for the async API,recv()
for the blocking API, etc.
import anyio
import zmq
import zmq_anyio
ctx = zmq.Context()
sock1 = ctx.socket(zmq.PAIR)
port = sock1.bind("tcp://127.0.0.1:1234")
sock2 = ctx.socket(zmq.PAIR)
sock2.connect("tcp://127.0.0.1:1234")
# wrap the `zmq.Socket` with `zmq_anyio.Socket`:
sock1 = zmq_anyio.Socket(sock1)
sock2 = zmq_anyio.Socket(sock2)
async def main():
async with sock1, sock2: # use an async context manager
await sock1.asend(b"Hello") # use `asend` instead of `send`
assert await sock2.arecv() == b"Hello" # use `arecv` instead of `recv`
anyio.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
zmq_anyio-0.2.3.tar.gz
(16.3 kB
view details)
Built Distribution
zmq_anyio-0.2.3-py3-none-any.whl
(14.5 kB
view details)
File details
Details for the file zmq_anyio-0.2.3.tar.gz
.
File metadata
- Download URL: zmq_anyio-0.2.3.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e1c676b7cef4fda7edac93051a68ff4ba529c2e841a87a290a9f52f8dcd1454 |
|
MD5 | c4b4bad4c3e5485ed47eec9ea469d3e0 |
|
BLAKE2b-256 | 813a968f26cb511b641398b0c23da159b906a11a17b37486ce7813ef8924fc7d |
Provenance
The following attestation bundles were made for zmq_anyio-0.2.3.tar.gz
:
Publisher:
publish.yml
on davidbrochart/zmq-anyio
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
zmq_anyio-0.2.3.tar.gz
- Subject digest:
0e1c676b7cef4fda7edac93051a68ff4ba529c2e841a87a290a9f52f8dcd1454
- Sigstore transparency entry: 148918254
- Sigstore integration time:
- Predicate type:
File details
Details for the file zmq_anyio-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: zmq_anyio-0.2.3-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe1b17b1139cec973ff84d08a04d95382e3af1e24d5a342abbf02fdcc40c8943 |
|
MD5 | fed0e5c9e1260d718fdd296a5cdc4581 |
|
BLAKE2b-256 | c8c6c2189e70565dcea66ac3afae1bab234daa638b104fe813d94d2b3ed07a4c |
Provenance
The following attestation bundles were made for zmq_anyio-0.2.3-py3-none-any.whl
:
Publisher:
publish.yml
on davidbrochart/zmq-anyio
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
zmq_anyio-0.2.3-py3-none-any.whl
- Subject digest:
fe1b17b1139cec973ff84d08a04d95382e3af1e24d5a342abbf02fdcc40c8943
- Sigstore transparency entry: 148918257
- Sigstore integration time:
- Predicate type: