engin 0.1.0b4__py3-none-any.whl → 0.1.0b5__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 +18 -17
- {engin-0.1.0b4.dist-info → engin-0.1.0b5.dist-info}/METADATA +1 -1
- {engin-0.1.0b4.dist-info → engin-0.1.0b5.dist-info}/RECORD +6 -6
- {engin-0.1.0b4.dist-info → engin-0.1.0b5.dist-info}/WHEEL +0 -0
- {engin-0.1.0b4.dist-info → engin-0.1.0b5.dist-info}/entry_points.txt +0 -0
- {engin-0.1.0b4.dist-info → engin-0.1.0b5.dist-info}/licenses/LICENSE +0 -0
engin/_engin.py
CHANGED
@@ -10,7 +10,7 @@ from itertools import chain
|
|
10
10
|
from types import FrameType
|
11
11
|
from typing import ClassVar
|
12
12
|
|
13
|
-
from anyio import create_task_group,
|
13
|
+
from anyio import create_task_group, open_signal_receiver
|
14
14
|
|
15
15
|
from engin._assembler import AssembledDependency, Assembler
|
16
16
|
from engin._dependency import Invoke, Provide, Supply
|
@@ -149,7 +149,7 @@ class Engin:
|
|
149
149
|
except Exception as err:
|
150
150
|
name = invocation.dependency.name
|
151
151
|
LOG.error(f"invocation '{name}' errored, exiting", exc_info=err)
|
152
|
-
|
152
|
+
raise
|
153
153
|
|
154
154
|
lifecycle = await self._assembler.build(Lifecycle)
|
155
155
|
|
@@ -177,10 +177,11 @@ class Engin:
|
|
177
177
|
try:
|
178
178
|
async with supervisor:
|
179
179
|
await self._stop_requested_event.wait()
|
180
|
-
|
181
|
-
|
180
|
+
await self._shutdown()
|
181
|
+
except BaseException:
|
182
|
+
await self._shutdown()
|
183
|
+
|
182
184
|
tg.cancel_scope.cancel()
|
183
|
-
await self._shutdown()
|
184
185
|
|
185
186
|
async def start(self) -> None:
|
186
187
|
"""
|
@@ -217,7 +218,8 @@ class Engin:
|
|
217
218
|
started.
|
218
219
|
"""
|
219
220
|
self._stop_requested_event.set()
|
220
|
-
|
221
|
+
if self._state == _EnginState.RUNNING:
|
222
|
+
await self._stop_complete_event.wait()
|
221
223
|
|
222
224
|
def graph(self) -> list[Node]:
|
223
225
|
"""
|
@@ -236,24 +238,23 @@ class Engin:
|
|
236
238
|
return self._state == _EnginState.SHUTDOWN
|
237
239
|
|
238
240
|
async def _shutdown(self) -> None:
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
241
|
+
if self._state == _EnginState.RUNNING:
|
242
|
+
LOG.info("stopping engin")
|
243
|
+
await self._exit_stack.aclose()
|
244
|
+
self._stop_complete_event.set()
|
245
|
+
LOG.info("shutdown complete")
|
246
|
+
self._state = _EnginState.SHUTDOWN
|
244
247
|
|
245
248
|
|
246
249
|
async def _stop_engin_on_signal(stop_requested_event: Event) -> None:
|
247
250
|
"""
|
248
251
|
A task that waits for a stop signal (SIGINT/SIGTERM) and notifies the given event.
|
249
252
|
"""
|
250
|
-
# try to gracefully handle sigint/sigterm
|
251
253
|
if not _OS_IS_WINDOWS:
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
await stop_requested_event.wait()
|
254
|
+
with open_signal_receiver(signal.SIGINT, signal.SIGTERM) as recieved_signals:
|
255
|
+
async for signum in recieved_signals:
|
256
|
+
LOG.debug(f"received {signum.name} signal")
|
257
|
+
stop_requested_event.set()
|
257
258
|
else:
|
258
259
|
should_stop = False
|
259
260
|
|
@@ -2,7 +2,7 @@ engin/__init__.py,sha256=O0vS570kZFBq7Kwy4FgeJFIhfo4aIg5mv_Z_9vAQRio,577
|
|
2
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=36trLrhXfKXf1t237qTZb_B3cnE3YvlzHA1c2JQfzN8,9453
|
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.0b5.dist-info/METADATA,sha256=k-K33xQpJTOGemxOVp0K8MlwKHFArl7LpyBdNKrWeS4,3201
|
23
|
+
engin-0.1.0b5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
24
|
+
engin-0.1.0b5.dist-info/entry_points.txt,sha256=sW247zZUMxm0b5UKYvPuqQQljYDtU-j2zK3cu7gHwM0,41
|
25
|
+
engin-0.1.0b5.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
|
26
|
+
engin-0.1.0b5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|