Replies: 5 comments 1 reply
-
Hi @hynek . I see you're back. What do you think of this change? I may be able to look into it soon. |
Beta Was this translation helpful? Give feedback.
-
heya, sorry for the delays – it's been… a lot. :) let me re-iterate what you want, because there was a bit of hence and forth: Your end-goal is to know whether the context block succeeded or not – correct? If so, I'm OK with the feature since it basically fulfills the standard context manager protocol that we're currently violating (on purpose and for good reasons) but I'm not super happy with the name, because it's a bit too general for a rather specific use case. How about something like: |
Beta Was this translation helpful? Give feedback.
-
Yes, fully agree. |
Beta Was this translation helpful? Give feedback.
-
Created draft PR with initial change #129 |
Beta Was this translation helpful? Give feedback.
-
this has been merged |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I got back to the problem I encountered in #112
My solution solved my local problem, but was simply wrong as generic improvement.
I got new idea. What about adding a new property
handles_exceptions: bool = False
to register_factory/RegisteredService?That way both cases would be handled correctly. The cleanup would be executed by default, but if the factory handles the exception, it would be able to clean up itself.
I'm curious what you think of that solution. My patch (unconditional passing of exception to context managers) works for me, but I'm not happy of maintaining it. If you agree with the idea, I may try to prepare a proper PR.
Close method would be altered to something like:
Beta Was this translation helpful? Give feedback.
All reactions