Skip to main content

Pulsar AsyncIO Client

Wrapper for pulsar-client that publishes messages asynchronously and handles consumed messages in an asyncio event loop.

Installation

$ pip install pulsar-asyncio-client

Usage

import asyncio
import pulsar_asyncio

PULSAR_URL = 'pulsar://localhost:6650'
PULSAR_TOPIC = 'non-persistent://public/default/my-topic'
PULSAR_SUBSCRIPTION = 'my-sub'

async def handle_message_async(consumer, message):
    message_text = message.data().decode('utf-8')
    print(f"Started asynchronously handling message: {message_text}")
    await asyncio.sleep(0.1)
    print(f"Finished asynchronously handling message: {message_text}")
    consumer.acknowledge(message)

async def main():
    # Init Pulsar client
    client = pulsar_asyncio.Client(PULSAR_URL)
    
    # Start a consumer with an async message listener
    consumer = client.subscribe(
        PULSAR_TOPIC,
        subscription_name=PULSAR_SUBSCRIPTION,
        message_listener=handle_message_async
    )

    # Asynchronously publish some messages
    producer = await client.create_producer(PULSAR_TOPIC)
    for i in range(10):
        message_text = f"My Message #{i}"
        print(f"About to asynchronously publish message: {message_text}")
        await producer.send(message_text.encode('utf-8'))

    # Allow some time for all messages to be consumed
    await asyncio.sleep(1)

    # Stop consumer
    consumer.close()
    
    # Stop client
    await client.close()

if __name__ == '__main__':
    asyncio.run(main())

Development

Install the development dependencies with PDM:

pdm install

Run lint and formatting checks:

pdm run lint

Apply automatic lint fixes and format the code:

pdm run lint-fix

Ruff checks Python errors, imports, common bug patterns, and Python 3.8-compatible modernization, and enforces consistent formatting. CI runs the same checks on pushes and pull requests. The generated pulsar_asyncio/version.py file is excluded.

Metadata

Release files for pulsar-asyncio-client 3.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pulsar-asyncio-client 3.5.0
File Size Uploaded
pulsar_asyncio_client-3.5.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pulsar-asyncio-client 3.5.0
File Interpreter ABI Platform
pulsar_asyncio_client-3.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / pulsar_asyncio_client-3.5.0.tar.gz

Download URL pulsar_asyncio_client-3.5.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ecd09ad4f9cc5caf7ea03d01bdbf2143c2bee3f0be248568622589f5092517c6
BLAKE2b-256 checksum
How to use checksums
3a4f7d618fccc35202fb29bddfefd868237215038fb7765c53a5fee34db783de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / pulsar_asyncio_client-3.5.0-py3-none-any.whl

Download URL pulsar_asyncio_client-3.5.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbb35d1603f063f8751ecebf73400d8bba461852c96e9e7abe83b83395ce0d1a
BLAKE2b-256 checksum
How to use checksums
60e048518f526385f4e7fa0e149811fc25f679d33f694e09223805a0181d4023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

3.13.0

2 release files

This release

3.5.0 This release

2 release files

0.1.0

2 release 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