On Jul 6, 2016, at 5:25 PM, Yury Selivanov <yselivanov@gmail.com> wrote:

The problem is that the GC can’t execute async code, and we don’t have any control over GC.  What if we add a mechanism to control how async generators (AG) are destructed.  Let’s say we add new function to the sys module - `sys.set_async_generator_finalizer(finalizer)`.  We already have sys.set_coroutine_wrapper(), so this isn’t something unprecedented.

There isn't just one event loop though, and what trampoline to attach a dying coroutine to depends heavily on what event loop it came from.  It seems like a single global value for this in 'sys' would just be ... wrong.

-glyph