Skip to content

Instantly share code, notes, and snippets.

@colophonemes
colophonemes / create_triggers
Last active September 6, 2024 18:00
Postgres TRIGGER to call NOTIFY with a JSON payload
CREATE TRIGGER person_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
'email',
'username'
);
CREATE TRIGGER income_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
@thehesiod
thehesiod / gather_cancel_children_on_exception.py
Last active September 27, 2022 08:55
asyncio cancel all tasks on first task's exception
import asyncio
import logging
from typing import List
def _ignore_task_exception(task: asyncio.Future, logger: logging.Logger):
# noinspection PyBroadException
try:
task.result()
except BaseException:
@artemonsh
artemonsh / docker-compose.yaml
Created November 24, 2023 20:06
FastAPI connect to Redis Pubsub and listen for messages on startup without blocking app
version: '3.8'
services:
cache:
image: redis:6.2-alpine
restart: always
ports:
- '6379:6379'