Pub/Sub with PostgreSQL under 40 lines of Python code
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio - listen.py
Pub/Sub with PostgreSQL under 40 lines of Python code launched on September 4, 2020 with 17 votes, #934 of 3,898 launches that month and more than 75% of that year's launches. The site was still online in September 2026, 6 years on.
In plain words
This is a Python implementation that demonstrates how to build a publish-subscribe messaging system using PostgreSQL in under 40 lines of code. It is for developers who need a lightweight pub/sub solution without external dependencies. The implementation showcases how PostgreSQL's built-in features can handle message queuing and subscription patterns, making it useful for those wanting to understand pub/sub mechanics or integrate simple messaging into Python applications that already use PostgreSQL.
written from the facts on this page · September 2026
From the sources
Anyone knows why conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) is important here? Not doubting that it is important. Because when I took the line out, the program didn't work. Just asking out of curiosity. psycopg2 is implemented according to PEP-249 (Python Database API Specification v2.0, "dbapi" for short), which states: Note that if the database supports an auto-commit feature, this must be initially off. So at every statement, a transaction is implicitly opened, but not committed, so whenever you want to finish the transaction, you have to explicitly COMMIT , unless you turn on "autocommit" mode ( Django does this by default , deviating from PEP 249 ), which…from gist.github.com
Does a similar job
all alternatives →
PgQueuer – Transform PostgreSQL into a Job Queue2024 · github.com · ▲376PgQueuer is a Python job queue that uses PostgreSQL for everything — queue storage, locking, notifications. No Redis, no RabbitMQ, no separate broker to operate. If your app already has Postgres, you already have the broker. After ~2 years and 26 minor releases, 1.0 ships today as the first stable release. Strict semver from here on. Thanks to everyone who contributed and left feedback!
Honker – Postgres NOTIFY/LISTEN Semantics for SQLiteApr 2026 · github.com · ▲327SQLite extension + bindings for Postgres NOTIFY/LISTEN semantics with durable queues, streams, pub/sub, and scheduler - russellromney/honker
PostgreSQL Pub/Sub for Node/TypeScript2020 · github.com · ▲5listen, notify, postgres, pubsub, javascript, typescript
- PSPeerdb Streams – Simple, native Postgres change data capture2024 · ▲177
Hello HN, I am Sai Srirampur, one of the Co-founders of PeerDB. (https://github.com/PeerDB-io/peerdb). We spent the past 7 months building a solid experience to replicate data from Postgres to data warehouses. Now we're expanding to queues. PeerDB Streams provides a simple and native way to replicate changes as they happen in Postgres to Queues (Kafka, Redpanda, Google PubSub, etc). We use Postgres logical decoding to enable Change Data Capture (CDC). Blog post here: https://blog.peerdb.io/peerdb-streams-simple-native-postgres.... 10-min quickstart here:…
- 1R1M rows/s from Postgres to Python2016 · magic.io · ▲296
An SQS Alternative on Postgres2024 · github.com · ▲241A lightweight message queue. Like AWS SQS and RSMQ but on Postgres. - pgmq/pgmq
More dev tools this month
the category →

open-source IDE for thoughtful software design. Contribute to devdotfast/whiteboard development by creating an account on GitHub.
Dev tools · 27d ago · github.com

Contribute to reladraw/reladraw development by creating an account on GitHub.
Dev tools · 25d ago · github.com
OpenBot▲362Grok Bot alternative: free, local, open-source, multiplayer
Dev tools · 23d ago · openbot.run
Talanoa▲343Hi HN, I’m a fullstack developer, and honestly, I’ve lost count of how many side projects I’ve worked on over the years. But one idea kept coming back to me: a different kind of email client. It first came to me in 2014: “What if we could handle emails more like conversations?” Every year, I’d revisit this concept in my “Build Notes.” Ten years later, no one had built exactly what I had in mind — so I finally decided to do it myself. That’s how Talanoa was born. I wanted something focused on people, not timelines. I was tired of marking messages as unread just to remember to reply later, or…
Dev tools · 20d ago · talanoa.email
CoreSpeed▲332One MCP for everything your agents need: apps, memory, tools
Dev tools · 28d ago · corespeed.io
Source: Show HN post ↗
Launched alongside, September 2020
the whole month →

Tables by Google▲783Tables helps teams easily track & automate tasks
Work · 2020 · tables.area120.google.com
- LS
Almost eight years ago I launched an online “Linux sysadmin course for newbies” here at HN. It was a side-project that went well, but never generated enough money to allow me to fully commit to leaving the Day Job. After surviving the Big C, and getting made redundant I thought I might improve and relaunch it commercially – but my doctors are a pessimistic bunch, so it looked like I didn’t have the time. Instead, I rejigged/relaunched it via a Reddit forum this February as free and open - and have now gathered a team of helpers to ensure that it keeps going each month even after I can’t…
Commerce · 2020

