Decorators for Coroutines
Learn how to use decorators when working with asynchronous programming.
Difficulties with decorating coroutines
Since pretty much everything in Python is an object, pretty much anything can be decorated, and this includes coroutines as well. Coroutines are functions that can be suspended and resumed during execution, and are essential for enabling concurrency in programs.
However, there's a caveat here, and that is that asynchronous programming in Python introduces some differences in syntax. Therefore, these syntax differences will also be carried to the decorator.
Simply speaking, if we were to write a decorator for a coroutine, we could simply adapt to the new syntax. (Remember to await the wrapped coroutine and define the wrapped object as a coroutine itself, ...