modal-labs / synchronicity

Synchronicity lets you interoperate with asynchronous Python APIs.
Apache License 2.0
80 stars 3 forks source link

Make synchronizer a context manager for managing event loop life cycle explicitly #158

Open freider opened 1 month ago

freider commented 1 month ago

Can also still be used lazily for usages outside of context manager

An advantage of using the context manager is that the event loop can be cleaned up gracefully before the interpreter shuts down, preventing issues with "trying to schedule call after executor shutdown" and other shutdown races/warnings.