[issue23519] using asyncio.iscoroutinefunction() on a functools.partial object

Mathieu Pasquet report at bugs.python.org
Thu Feb 26 14:26:20 CET 2015


Mathieu Pasquet added the comment:

Using functools.partial with coroutines would be mostly out of convenience, in order to avoid having factories in that return parametrized coroutine functions. I guess in such cases it might be better to create a two-lines wrapper around partial() to make it return a coroutine rather than change the stdlib for that.

In the attached file is an example of such use, where EventNotifier is a Protocol which receives external events and triggers event handlers based on that, and where the add_event_handler function checks if the handler is a coroutine function. In which case it uses asyncio.async to schedule the handler call; otherwise it uses loop.call_soon.

You can close this, I guess.

----------
Added file: http://bugs.python.org/file38246/example_partial.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23519>
_______________________________________


More information about the Python-bugs-list mailing list