Generator-based coroutines being deprecated in python 3.7

Viewed 610

Generator-based coroutines were being deprecated in python 3.7 and scheduled for removal in python 3.10.

The use of @asyncio.coroutine was also deprecated in python 3.7 and scheduled for removal in python 3.10. It already issues a deprecation warning if used.

On the other hand, @types.coroutine is not said to be deprecated and doesn't issue a warning.

Another SO discussion on the subject already noted that @asyncio.coroutine uses @types.coroutine and adds the deprecation warning, among other stuff.

The use of @types.coroutine is required for awaiting on generator-based coroutines, otherwise you get the error:

"object generator can't be used in 'await' expression"

(The use of generators to create coroutines is still relevant when you have a value at hand that you just wish to yield as is - not yield from).

Would the @types.coroutine decorator remain valid in future python versions?

In case it remains valid, would generators decorated with @types.coroutine be considered as valid coroutines, i.e. not fall under the deprecation of generator-based coroutines?

0 Answers
Related