agronholm / apscheduler

Task scheduling library for Python
MIT License
5.93k stars 690 forks source link

refactor: Create `AsyncExitStack` using `attrs` factory #907

Closed injust closed 1 month ago

injust commented 1 month ago

A bit nicer to have attrs create the AsyncExitStack, instead of assigning self._exit_stack = exit_stack.pop_all() from within the with block.

injust commented 1 month ago

Seems like the Windows tests are broken. Failures aren't relevant to my change and also happen in other PRs.

agronholm commented 1 month ago

You're changing the semantics for the worse. The reason I'm doing async with AsyncExitStack(): in __aenter__() is to ensure that the stack gets rewound if there's an unhandled exception during __aenter__(). This would no longer happen if I were to merge this PR.

injust commented 1 month ago

You're changing the semantics for the worse. The reason I'm doing async with AsyncExitStack(): in __aenter__() is to ensure that the stack gets rewound if there's an unhandled exception during __aenter__(). This would no longer happen if I were to merge this PR.

Thanks for the explanation; I learned a thing today. Didn't think hard enough about exception handling within __aenter__().