Skip to main content

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 zmq_anyio.Socket from a zmq.Socket or from a zmq.Context:
    • Create a blocking ZMQ socket using a zmq.Context, and pass it to an async zmq_anyio.Socket:
      ctx = zmq.Context()
      sock = ctx.socket(zmq.PAIR)
      asock = zmq_anyio.Socket(sock)
      
    • Or create an async zmq_anyio.Socket using a zmq.Context:
      ctx = zmq.Context()
      asock = zmq_anyio.Socket(ctx)
      
  • 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` and await it
        sock1.asend(b", World!")  # or don't await it, it's sent in the background
        assert await sock2.arecv() == b"Hello"  # use `arecv` instead of `recv`
        future = sock2.arecv()  # or get the future and await it later
        assert await future == b", World!"

anyio.run(main)

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.4.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zmq_anyio-0.4.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zmq_anyio-0.4.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zmq_anyio-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e811dec0b450e119170e6439b9a6fad20db7bdf32ed3a36cadddbc9fc4d9c268
MD5 cb88a828f4ac08ba7dcba712d921f693
BLAKE2b-256 90603b03978be292cf2b3c4308ca943ef7814da238befa6ef927fa1a0acc4190

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on QuantStack/zmq-anyio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: zmq_anyio-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zmq_anyio-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 879b5963cb3d3ecc273da29020f27107982a68fec6c572317b33c6b561a86d88
MD5 980bb1dba27318b676fde93dfbd1f759
BLAKE2b-256 9c672a9ed8a0c2ec65d2081553521e74d696543f79122193449e7fc5a66d40f8

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on QuantStack/zmq-anyio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page