From cf46c59f70ef5cd6015517e6fcd9ec8c874f4efb Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Sat, 19 Sep 2026 14:39:09 +0300 Subject: [PATCH] docs: say the per-job child is built open, not unopened --- modern_di_arq/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modern_di_arq/main.py b/modern_di_arq/main.py index 5f0ad0d..d12e765 100644 --- a/modern_di_arq/main.py +++ b/modern_di_arq/main.py @@ -97,11 +97,12 @@ def setup_di(worker_settings: typing.Any, container: Container) -> Container: # Seeds the root container into the worker ``ctx`` (arq's state store) and wraps the worker's lifecycle hooks: ``on_startup``/``on_shutdown`` open and - close the root; ``on_job_start`` builds an unopened ``Scope.REQUEST`` child - per job, opened and closed by ``@inject``-decorated task(s) around their - own bodies — reference-counted, so nested and concurrent (``asyncio.gather``) - ``@inject`` calls over the same job share one open child, closed exactly - once by the last to exit (``on_job_end`` only closes it as a safety net). + close the root; ``on_job_start`` builds one ``Scope.REQUEST`` child per job + (open from construction, as modern-di containers are); ``@inject``-decorated + task(s) narrow its lifetime to their own bodies — reference-counted, so nested + and concurrent (``asyncio.gather``) ``@inject`` calls over the same job share + that one child, closed exactly once by the last to exit (``on_job_end`` only + closes it as a safety net). Any hook the user already set still runs. Accepts a class/object ``worker_settings`` (attribute access) or a ``dict`` (item access). Returns *container*.