Skip to content

Instantly share code, notes, and snippets.

View OfferLifted's full-sized avatar

OfferLifted OfferLifted

View GitHub Profile
@OfferLifted
OfferLifted / asyncio_taskgroup_showcase.py
Created May 6, 2024 17:59
Showcase of using asyncio's TaskGroup with nested TaskGroups and handling errors in a centralised place.
import asyncio
trigger_exception_event = asyncio.Event()
async def coro_1():
for _ in range(10):
print("I'm coro 1 from tg 1")
await asyncio.sleep(1)
@OfferLifted
OfferLifted / enum_bench.py
Created June 8, 2024 08:07
Simple bench of enum vs class with inst var and cls var.
import timeit
from enum import Enum
class RestartReasonEnum(Enum):
WS_NOT_OPEN = "WS NOT OPEN"
NO_MESSAGES = "NO MESSAGES FOR > 15 SEC"
LISTEN_TASK_DONE = "LISTEN TASK DONE"
COUNT_TOO_HIGH = "COUNT TOO HIGH"