When a dependency is yielded within a function decorated with @inject, it is expected that the entire dependency coroutine would execute to completion before any subsequent code is executed. However, in scenarios where the application is terminated abruptly, the coroutine seems to be interrupted before it completes its execution.
To illustrate the issue, I've provided a minimal example below:
In the provided example, the text "after" is expected to be printed after the value 10 is yielded from the sample_dep coroutine. However, if the application is terminated abruptly, such as by a keyboard interrupt, the "after" text is not printed, indicating that the coroutine was not allowed to complete its execution.
I believe this behavior may lead to unexpected results and could potentially cause issues in real-world applications where the completion of dependencies is crucial (like database or broker connections)
Could you please investigate this behavior and provide guidance on how to ensure that yielded dependencies are executed to completion even in scenarios of abnormal termination?
Appreciate your assistance with this matter and your contributions to this awesome library.
Thank you.
Python version:
3.12.2
When a dependency is yielded within a function decorated with
@inject
, it is expected that the entire dependency coroutine would execute to completion before any subsequent code is executed. However, in scenarios where the application is terminated abruptly, the coroutine seems to be interrupted before it completes its execution.To illustrate the issue, I've provided a minimal example below:
In the provided example, the text
"after"
is expected to be printed after the value 10 is yielded from thesample_dep
coroutine. However, if the application is terminated abruptly, such as by a keyboard interrupt, the "after" text is not printed, indicating that the coroutine was not allowed to complete its execution.I believe this behavior may lead to unexpected results and could potentially cause issues in real-world applications where the completion of dependencies is crucial (like database or broker connections)
Could you please investigate this behavior and provide guidance on how to ensure that yielded dependencies are executed to completion even in scenarios of abnormal termination?
Appreciate your assistance with this matter and your contributions to this awesome library. Thank you.