Title: asyncio.coroutine decorator returns a non-generator function when using PYTHONASYNCIODEBUG
Type: behavior Stage:
Components: asyncio Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: a-feld, asvetlov, yselivanov
Priority: normal Keywords:

Created on 2020-06-30 17:14 by a-feld, last changed 2020-06-30 17:14 by a-feld.

Messages (1)
msg372706 - (view) Author: Allan Feldman (a-feld) * Date: 2020-06-30 17:14
This code behaves differently when PYTHONASYNCIODEBUG=1

import asyncio
import inspect

def foo():
    yield from asyncio.sleep(0)

print("isgeneratorfunction:", inspect.isgeneratorfunction(foo))

isgeneratorfunction: False

non-debug mode:
isgeneratorfunction: True

When in debug mode, the `asyncio.coroutine` decorator returns a function that is not a generator function (

The result is that introspection of functions is changed when PYTHONASYNCIODEBUG is enabled.
Date User Action Args
2020-06-30 17:14:21a-feldcreate