Keep an async function marker when @pass_
is used
#79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately, when the
@picobox.pass_()
decorator is used, a wrapped coroutine function (i.e. an async function) loses its a coroutine function marker, i.e.inspect.iscoroutinefunction()
returnsFalse
for such function.Turns out that there are a lot of software out there that support both sync and async interfaces, and may choose one based on the type of a passed function. For instance, Starlette, a web-framework, checks a provided route function for being a coroutine function before choosing how to execute in (i.e. in an event loop or in a thread pool).
This patch fixes
@picobox.pass_()
to return a coroutine function when a wrapped function is also a coroutine function.Fixes #78