engin 0.1.0b2__py3-none-any.whl → 0.1.0b4__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/_assembler.py +7 -5
- engin/_engin.py +19 -1
- {engin-0.1.0b2.dist-info → engin-0.1.0b4.dist-info}/METADATA +1 -1
- {engin-0.1.0b2.dist-info → engin-0.1.0b4.dist-info}/RECORD +7 -7
- {engin-0.1.0b2.dist-info → engin-0.1.0b4.dist-info}/WHEEL +0 -0
- {engin-0.1.0b2.dist-info → engin-0.1.0b4.dist-info}/entry_points.txt +0 -0
- {engin-0.1.0b2.dist-info → engin-0.1.0b4.dist-info}/licenses/LICENSE +0 -0
engin/_assembler.py
CHANGED
@@ -65,7 +65,7 @@ class Assembler:
|
|
65
65
|
self._multiproviders: dict[TypeId, list[Provide[list[Any]]]] = defaultdict(list)
|
66
66
|
self._assembled_outputs: dict[TypeId, Any] = {}
|
67
67
|
self._lock = asyncio.Lock()
|
68
|
-
self._graph_cache: dict[TypeId,
|
68
|
+
self._graph_cache: dict[TypeId, list[Provide]] = defaultdict(list)
|
69
69
|
|
70
70
|
for provider in providers:
|
71
71
|
type_id = provider.return_type_id
|
@@ -206,10 +206,10 @@ class Assembler:
|
|
206
206
|
if provider.scope == scope:
|
207
207
|
self._assembled_outputs.pop(type_id, None)
|
208
208
|
|
209
|
-
def _resolve_providers(self, type_id: TypeId, resolved: set[TypeId]) ->
|
209
|
+
def _resolve_providers(self, type_id: TypeId, resolved: set[TypeId]) -> Iterable[Provide]:
|
210
210
|
"""
|
211
211
|
Resolves the chain of providers required to satisfy the provider of a given type.
|
212
|
-
Ordering of the return value is very important!
|
212
|
+
Ordering of the return value is very important here!
|
213
213
|
"""
|
214
214
|
if type_id in self._graph_cache:
|
215
215
|
return self._graph_cache[type_id]
|
@@ -231,13 +231,15 @@ class Assembler:
|
|
231
231
|
raise LookupError(msg)
|
232
232
|
|
233
233
|
# providers that must be satisfied to satisfy the root level providers
|
234
|
-
resolved_providers =
|
234
|
+
resolved_providers = [
|
235
235
|
child_provider
|
236
236
|
for root_provider in root_providers
|
237
237
|
for root_provider_param in root_provider.parameter_type_ids
|
238
238
|
for child_provider in self._resolve_providers(root_provider_param, resolved)
|
239
239
|
if root_provider_param not in resolved
|
240
|
-
|
240
|
+
]
|
241
|
+
|
242
|
+
resolved_providers.extend(root_providers)
|
241
243
|
|
242
244
|
resolved.add(type_id)
|
243
245
|
self._graph_cache[type_id] = resolved_providers
|
engin/_engin.py
CHANGED
@@ -188,7 +188,25 @@ class Engin:
|
|
188
188
|
started to return so it is safe to use immediately after.
|
189
189
|
"""
|
190
190
|
self._async_context_run_task = asyncio.create_task(self.run())
|
191
|
-
|
191
|
+
wait_tasks = [
|
192
|
+
asyncio.create_task(self._start_complete_event.wait()),
|
193
|
+
asyncio.create_task(self._stop_complete_event.wait()),
|
194
|
+
]
|
195
|
+
await asyncio.wait(
|
196
|
+
[
|
197
|
+
self._async_context_run_task, # if a provider errors this will return first
|
198
|
+
*wait_tasks,
|
199
|
+
],
|
200
|
+
return_when=asyncio.FIRST_COMPLETED,
|
201
|
+
)
|
202
|
+
for task in wait_tasks:
|
203
|
+
task.cancel()
|
204
|
+
|
205
|
+
# raise the exception from the startup during run
|
206
|
+
if self._async_context_run_task.done():
|
207
|
+
startup_exception = self._async_context_run_task.exception()
|
208
|
+
if startup_exception is not None:
|
209
|
+
raise startup_exception
|
192
210
|
|
193
211
|
async def stop(self) -> None:
|
194
212
|
"""
|
@@ -1,8 +1,8 @@
|
|
1
1
|
engin/__init__.py,sha256=O0vS570kZFBq7Kwy4FgeJFIhfo4aIg5mv_Z_9vAQRio,577
|
2
|
-
engin/_assembler.py,sha256
|
2
|
+
engin/_assembler.py,sha256=MC14BRsgabGlq9weyv2VXylH4RE282uNTyNH5rN8Lqc,11359
|
3
3
|
engin/_block.py,sha256=IacP4PoJKRhSQCbQSdoyCtmu362a4vj6qoUQKyaJwzI,3062
|
4
4
|
engin/_dependency.py,sha256=xINk3sudxzsTmkUkNAKQwzBc0G0DfhpnrZli4z3ALBY,9459
|
5
|
-
engin/_engin.py,sha256=
|
5
|
+
engin/_engin.py,sha256=GASnv9x0Qrrok_4zGbaFm7wWZqYNAZ55w0vU3Z-gn8g,9343
|
6
6
|
engin/_graph.py,sha256=y1g7Lm_Zy5GPEgRsggCKV5DDaDzcwUl8v3IZCK8jyGI,1631
|
7
7
|
engin/_introspect.py,sha256=VdREX6Lhhga5SnEP9G7mjHkgJR4mpqk_SMnmL2zTcqY,966
|
8
8
|
engin/_lifecycle.py,sha256=cSWe3euZkmpxmUPFvph2lsTtvuZbxttEfBL-RnOI7lo,5325
|
@@ -19,8 +19,8 @@ engin/_cli/_inspect.py,sha256=0jm25d4wcbXVNJkyaeECSKY-irsxd-EIYBH1GDW_Yjc,3163
|
|
19
19
|
engin/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
20
|
engin/extensions/asgi.py,sha256=d5Z6gtMVWDZdAlvrTaMt987sKyiq__A0X4gJQ7IETmA,3247
|
21
21
|
engin/extensions/fastapi.py,sha256=7N6i-eZUEZRPo7kcvjS7kbRSY5QAPyKJXSeongSQ-OA,6371
|
22
|
-
engin-0.1.
|
23
|
-
engin-0.1.
|
24
|
-
engin-0.1.
|
25
|
-
engin-0.1.
|
26
|
-
engin-0.1.
|
22
|
+
engin-0.1.0b4.dist-info/METADATA,sha256=GrfuoOkM35Dcjdjzf22LlZ_EgHhn7KtzMGEOybLhoxo,3201
|
23
|
+
engin-0.1.0b4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
24
|
+
engin-0.1.0b4.dist-info/entry_points.txt,sha256=sW247zZUMxm0b5UKYvPuqQQljYDtU-j2zK3cu7gHwM0,41
|
25
|
+
engin-0.1.0b4.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
|
26
|
+
engin-0.1.0b4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|