Skip to content

Instantly share code, notes, and snippets.

@benfasoli
benfasoli / limit_asyncio_concurrency_example.py
Created January 23, 2022 17:18
Limit concurrency with Python asyncio
import asyncio
from typing import Coroutine, List, Sequence
def _limit_concurrency(
coroutines: Sequence[Coroutine], concurrency: int
) -> List[Coroutine]:
"""Decorate coroutines to limit concurrency.
Enforces a limit on the number of coroutines that can run concurrently in higher
@juanpabloaj
juanpabloaj / logging_env.py
Last active August 17, 2024 17:49
python logging, log level with environment variable
import os
import logging
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL, format="%(asctime)s %(message)s")