Skip to main content

asyncpg-listen

This library simplifies usage of listen/notify with asyncpg:

  1. Handles loss of a connection
  2. Simplifies notifications processing from multiple channels
  3. Setups a timeout for receiving a notification
  4. Allows to receive all notifications/only last notification depending on ListenPolicy.
import asyncio
import asyncpg
import asyncpg_listen


async def handle_notifications(notification: asyncpg_listen.NotificationOrTimeout) -> None:
    print(f"{notification} has been received")


async def main():
    listener = asyncpg_listen.NotificationListener(asyncpg_listen.connect_func(user="postgres"))
    listener_task = asyncio.create_task(
        listener.run(
            {"simple": handle_notifications},
            policy=asyncpg_listen.ListenPolicy.LAST,
            notification_timeout=5
        )
    )

    await asyncio.sleep(1)

    connection = await asyncpg.connect(user="postgres")
    try:
        for i in range(42):
            await connection.execute(f"NOTIFY simple, '{i}'")
    finally:
        await connection.close()

    await asyncio.sleep(1)

    listener_task.cancel()


asyncio.run(main())

v0.0.9 (2025-07-16)

SELECT 1 only if we haven't seen any events

No need to wait for a connection closure

v0.0.8 (2025-05-25)

  • Support python 3.13

v0.0.7 (2024-09-07)

v0.0.6 (2022-11-02)

v0.0.5 (2022-05-23)

v0.0.4 (2022-01-24)

v0.0.3 (2022-01-23)

v0.0.2 (2021-11-02)

v0.0.1 (2021-10-27)

  • A first version

Metadata

Release files for asyncpg-listen 0.0.9

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

Source distribution (sdist)

Source distribution for asyncpg-listen 0.0.9
File Size Uploaded Provenance Actions
asyncpg-listen-0.0.9.tar.gz 8.0 kB Without provenance Details for asyncpg-listen-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asyncpg-listen 0.0.9
File Interpreter ABI Platform Actions
asyncpg_listen-0.0.9-py3-none-any.whl Python 3 none any Details for asyncpg_listen-0.0.9-py3-none-any.whl

Total release size: 13.9 kB

Release files / asyncpg-listen-0.0.9.tar.gz

Download URL asyncpg-listen-0.0.9.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f94c4752f7ca1077eaaad0fa2c08fcef4990eaae81a61c423683a722ca3f3a33
BLAKE2b-256 checksum
How to use checksums
31d70491b438a8d97128e52441d5dc09c4a975b662da8e05da53974146fce939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / asyncpg_listen-0.0.9-py3-none-any.whl

Download URL asyncpg_listen-0.0.9-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44a4fe25a589de71bb8822aa3db6dde6e32d7f95c8e6b674be037473ca1f2775
BLAKE2b-256 checksum
How to use checksums
e5215fe6b94db1f34d84590c7e997d76d11d11af87c6f4048dfd6f4c97325e4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Security for asyncpg-listen 0.0.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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