
On 7/4/22 11:21, Jean-Paul Calderone wrote:
Hello,
I've just written up an idea for an approach to getting many parts of Twisted and Twisted-based applications onto coroutines (ie `async def`).
[quietly, from the house across the street] woo! yeah! right on! ... In terms of returning a coroutine, I believe that Python (especially under ASYNCIODEBUG=1) gets annoyed and spews warnings if a coroutine is not awaited (I believe when it is GC'd). Because returning a coroutine without scheduling it is possibly able to run into this case (e.g. a coroutine that performs a 'send clean goodbye' that is not scheduled until the connection is started to be shut down, but is never called on an unclean shutdown, just as a strawman), I think that it is completely valid to ignore it. Especially since returning a function-that-returns-a-couroutine that you then call when you need it is 1000x better of an API. That is to say, from my increasingly rusty memory of how all of this works, I believe this is a good way to go. - Amber