Skip to main content

Asynchronous API for ZMQ using AnyIO

Project description

Build Status

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 blocking ZMQ socket sock using a zmq.Context.
  • Create an async zmq_anyio.Socket(sock), passing the sock.
  • 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.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

zmq_anyio-0.2.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file zmq_anyio-0.2.1.tar.gz.

File metadata

  • Download URL: zmq_anyio-0.2.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for zmq_anyio-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d40d27fadba57031ee146d314fd41c174f3708506cdee886b501c0e90abd8aca
MD5 c5db5cff4ea190c8673d3ad46a6cea97
BLAKE2b-256 2932e5f5996825cf026829ed4143f1b241f06a0c3ea2d89ea513eb2c7bd93596

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmq_anyio-0.2.1.tar.gz:

Publisher: publish.yml on davidbrochart/zmq-anyio

Attestations:

File details

Details for the file zmq_anyio-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: zmq_anyio-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for zmq_anyio-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f478bb36de6dbf341fd7a65cae2fc19eb9616d75e2ef53df600a3598eaa7c4c4
MD5 ef6aa35e7fe0e2c0743924c048693dc4
BLAKE2b-256 86ea7dd12bde73a65275bc320b75440842efcbbd8caedab6f6476783c6da06d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmq_anyio-0.2.1-py3-none-any.whl:

Publisher: publish.yml on davidbrochart/zmq-anyio

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page