engin 0.0.5__py3-none-any.whl → 0.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
engin/_engin.py
CHANGED
@@ -81,8 +81,6 @@ class Engin:
|
|
81
81
|
Args:
|
82
82
|
*options: an instance of Provide, Supply, Invoke, Entrypoint or a Block.
|
83
83
|
"""
|
84
|
-
self._providers: dict[TypeId, Provide] = {TypeId.from_type(Engin): Provide(self._self)}
|
85
|
-
self._invokables: list[Invoke] = []
|
86
84
|
|
87
85
|
self._stop_requested_event = Event()
|
88
86
|
self._stop_complete_event = Event()
|
@@ -90,8 +88,16 @@ class Engin:
|
|
90
88
|
self._shutdown_task: Task | None = None
|
91
89
|
self._run_task: Task | None = None
|
92
90
|
|
91
|
+
# TODO: refactor _destruct_options and related attributes into a dedicated class?
|
92
|
+
self._providers: dict[TypeId, Provide] = {TypeId.from_type(Engin): Provide(self._self)}
|
93
|
+
self._multiproviders: dict[TypeId, list[Provide]] = {}
|
94
|
+
self._invocations: list[Invoke] = []
|
95
|
+
# populates the above
|
93
96
|
self._destruct_options(chain(self._LIB_OPTIONS, options))
|
94
|
-
|
97
|
+
multi_providers = [p for multi in self._multiproviders.values() for p in multi]
|
98
|
+
self._assembler = Assembler(chain(self._providers.values(), multi_providers))
|
99
|
+
self._providers.clear()
|
100
|
+
self._multiproviders.clear()
|
95
101
|
|
96
102
|
@property
|
97
103
|
def assembler(self) -> Assembler:
|
@@ -119,7 +125,7 @@ class Engin:
|
|
119
125
|
"""
|
120
126
|
LOG.info("starting engin")
|
121
127
|
assembled_invocations: list[AssembledDependency] = [
|
122
|
-
await self._assembler.assemble(invocation) for invocation in self.
|
128
|
+
await self._assembler.assemble(invocation) for invocation in self._invocations
|
123
129
|
]
|
124
130
|
|
125
131
|
for invocation in assembled_invocations:
|
@@ -153,6 +159,8 @@ class Engin:
|
|
153
159
|
started.
|
154
160
|
"""
|
155
161
|
self._stop_requested_event.set()
|
162
|
+
if self._shutdown_task is None:
|
163
|
+
return
|
156
164
|
await self._stop_complete_event.wait()
|
157
165
|
|
158
166
|
async def _shutdown(self) -> None:
|
@@ -170,12 +178,19 @@ class Engin:
|
|
170
178
|
if isinstance(opt, Block):
|
171
179
|
self._destruct_options(opt)
|
172
180
|
if isinstance(opt, Provide | Supply):
|
173
|
-
|
174
|
-
|
175
|
-
|
181
|
+
if not opt.is_multiprovider:
|
182
|
+
existing = self._providers.get(opt.return_type_id)
|
183
|
+
self._log_option(opt, overwrites=existing)
|
184
|
+
self._providers[opt.return_type_id] = opt
|
185
|
+
else:
|
186
|
+
self._log_option(opt)
|
187
|
+
if opt.return_type_id in self._multiproviders:
|
188
|
+
self._multiproviders[opt.return_type_id].append(opt)
|
189
|
+
else:
|
190
|
+
self._multiproviders[opt.return_type_id] = [opt]
|
176
191
|
elif isinstance(opt, Invoke):
|
177
192
|
self._log_option(opt)
|
178
|
-
self.
|
193
|
+
self._invocations.append(opt)
|
179
194
|
|
180
195
|
@staticmethod
|
181
196
|
def _log_option(opt: Dependency, overwrites: Dependency | None = None) -> None:
|
@@ -2,7 +2,7 @@ engin/__init__.py,sha256=yTc8k0HDGMIrxDdEEA90qGD_dExQjVIbXCyaOFRrnMg,508
|
|
2
2
|
engin/_assembler.py,sha256=VCZA_Gq4hnH5LueB_vEVqsKbGXx-nI6KQ65YhzXw-VY,7575
|
3
3
|
engin/_block.py,sha256=-5qTp1Hdm3H54nScDGitFpcXRHLIyVHlDYATg_3dnPw,2045
|
4
4
|
engin/_dependency.py,sha256=oh1T7oR-c9MGcZ6ZFUgPnvHRf-n6AIvpbm59R97To80,5404
|
5
|
-
engin/_engin.py,sha256=
|
5
|
+
engin/_engin.py,sha256=Dp1i0COcmaXWwrckBq3-vym-B7umsZG_0vXjasA5y70,9002
|
6
6
|
engin/_exceptions.py,sha256=fsc4pTOIGHUh0x7oZhEXPJUTE268sIhswLoiqXaudiw,635
|
7
7
|
engin/_lifecycle.py,sha256=_jQnGFj4RYXsxMpcXPJQagFOwnoTVh7oSN8oUYoYuW0,3246
|
8
8
|
engin/_type_utils.py,sha256=C71kX2Dr-gluGSL018K4uihX3zkTe7QNWaHhFU10ZmA,2127
|
@@ -10,7 +10,7 @@ engin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
engin/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
engin/ext/asgi.py,sha256=6vuC4zIhsvAdmwRn2I6uuUWPYfqobox1dv7skg2OWwE,1940
|
12
12
|
engin/ext/fastapi.py,sha256=CH2Zi7Oh_Va0TJGx05e7_LqAiCsoI1qcu0Z59_rgfRk,899
|
13
|
-
engin-0.0.
|
14
|
-
engin-0.0.
|
15
|
-
engin-0.0.
|
16
|
-
engin-0.0.
|
13
|
+
engin-0.0.6.dist-info/METADATA,sha256=SSsLRciMAahwVMjw6Igdcq1jt1zv24FrPuXm_1uykjg,1806
|
14
|
+
engin-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
engin-0.0.6.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
|
16
|
+
engin-0.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|