Skip to content

Add nuke-di - #129

Open
troyan-dy wants to merge 1 commit into
timofurrer:mainfrom
troyan-dy:add-nuke-di
Open

troyan-dy wants to merge 1 commit into
timofurrer:mainfrom
troyan-dy:add-nuke-di

Conversation

@troyan-dy

Copy link
Copy Markdown

Adds nuke-di to Misc.

Why it is useful for asyncio applications:

  • An async lifecycle for every dependency. A dependency is a class with a type-hinted __init__ and async connect() / disconnect(). async with DI: connects every client as soon as its own dependencies have, concurrently with every other client that is ready, so startup takes as long as the longest chain of dependencies rather than the sum of all connections; clients disconnect in reverse order, and a failing disconnect() does not stop the others.
  • Processes with graceful shutdown. @worker runs an async function until SIGTERM, cancels it after a grace period and disconnects the clients; @job runs it once, with its annotated arguments parsed from the command line. Both exit with codes a scheduler can act on.
  • Framework integrations: FastAPI, Litestar, FastStream, aiogram, taskiq and MCP handlers take clients by type hint.
  • No runtime dependencies, Python 3.11+, MIT.

Following CONTRIBUTING: one link, description ends with a period, no mention of asyncio in it.

Disclosure: I am the author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant