Skip to main content

aiopg-listen

This library simplifies usage of listen/notify with aiopg:

  1. Handles lost of a connection
  2. Simplifies processing notifications from multiple channels
  3. Setups a timeout for receiving a notification
  4. Allows to receive all notifications/only last notification depends on ListenPolicy.
import asyncio
import aiopg
import aiopg_listen


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


listener = aiopg_listen.NotificationListener(aiopg_listen.connect_func())
listener_task = asyncio.create_task(
    listener.run(
        {"channel": handle_notifications},
        policy=aiopg_listen.ListenPolicy.LAST,
        notification_timeout=1
    )
)

async with aiopg.connect() as connection, connection.cursor() as cursor:
    for i in range(42):
        await cursor.execute(f"NOTIFY simple, '{i}'")

v0.0.7 (2023-03-09)

v0.0.6 (2022-11-02)

v0.0.5 (2021-11-02)

v0.0.4 (2021-09-08)

  • Reexport explicitly #18

v0.0.3 (2021-08-10)

  • Allow suppressing timeout by aiopg_listen.NO_TIMEOUT #9
  • Fix typing for python 3.8 #11

v0.0.2 (2021-07-25)

  • Add aiopg_listen.connect_func to simplify initialization #5
  • Rename consumer to listener #6
  • Do not crash if handler fails #7

v0.0.1 (2021-07-25)

  • A first version

Metadata

Release files for aiopg-listen 0.0.7

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

Source distribution (sdist)

Source distribution for aiopg-listen 0.0.7
File Size Uploaded
aiopg-listen-0.0.7.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiopg-listen 0.0.7
File Interpreter ABI Platform
aiopg_listen-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / aiopg-listen-0.0.7.tar.gz

Download URL aiopg-listen-0.0.7.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ddebe97d14088fc76f0afc76f85f281c3663bd033c688705bcdb454ffc9866e7
BLAKE2b-256 checksum
How to use checksums
4e1318535de2817239ea14c17d7db55cb38771e6b6c63eeb86ba878c9df39789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / aiopg_listen-0.0.7-py3-none-any.whl

Download URL aiopg_listen-0.0.7-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68332ead7f1bbb6445cc35aa61d55662f757db1aa7352473271d4a3cf1cb2f43
BLAKE2b-256 checksum
How to use checksums
68a2625253bcae9187c1538012a0f4016b736e563c751419736afb695fcc55ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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