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.1.tar.gz (12.6 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.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zmq_anyio-0.4.1.tar.gz
  • Upload date:
  • Size: 12.6 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.1.tar.gz
Algorithm Hash digest
SHA256 0c11c2fe0657987d545380d500e82587c0b636c67c98490f2c2682b2dcc96196
MD5 50e7f33f588e9e0fd0977b0a0b66c3a6
BLAKE2b-256 9a4ac35b1442613f686eb681a23f5a4528b8bc0391ae1b42ce835de075a18272

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmq_anyio-0.4.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: zmq_anyio-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4800f8fb824802cebde7ea042056d026e51cc90204f04018773920114b47ef58
MD5 6068c8b5f0fe35d68321af48acba8ec6
BLAKE2b-256 2fdcbc4ce04180cc1a106e07862736c2a5d78f7ab8f2e7c5b0ffe38a43e73f8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmq_anyio-0.4.1-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

This release

0.4.1 This release

2 files

0.4.0

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