Closed samuel-gauthier closed 6 years ago
I tried your change to the bus_monitor
script, and it works just fine with Python 3.5.5 on Debian Unstable. asyncio.iscoroutine
is documented to return True
on either a generator or a coroutine object; async def
creates a coroutine, not a generator, so that shouldn’t be the issue here.
Perhaps a bug in earlier versions of 3.5.x?
Hi again,
Actually my analysis was wrong, sorry about that. My problem is actually not related to this.
What happens is that PYTHONASYNCIODEBUG=1 changes the type of result (in the code below) from CoroutineType into a CoroWrapper type, whose type does not match CoroutineType. I have changed the issue title and description to make things clearer.
It is the asyncio debug mode that triggers the problem, because the CoroWrapper is not of coroutine type, but is catched properly by asyncio.iscoroutine. The script actually works fine without it.
I think it is worth fixing anyway, this debug mode of asyncio is useful (https://docs.python.org/3/library/asyncio-dev.html#debug-mode-of-asyncio). It seems safer to use asyncio's builtin too.
What do you think?
Yup, I can reproduce the problem. I agree debug mode is worth supporting. Fixed.
Thanks!
Hi,
Starting a script using dbussy with asyncio debug mode makes asynchronous dbus callbacks to stop being called. I tracked the problem down to when the coroutines are called, and it seems to be supported, but it ends up with a traceback.
I have written this patch on dbussy_example bus_monitor to illustrate the problem I face:
Then, launching bus_monitor with the asyncio debug mode :
My understanding of the problem is that the proper way to detect if an object is a coroutine is to use the asyncio function iscoroutine, instead of checking if the object is of CoroutineType.
Something like:
If I replace all the occurences of this isinstance(result, types.CoroutineType) by an asyncio.iscoroutine(result), I don't get the tracebacks anymore.