[issue23519] using asyncio.iscoroutinefunction() on a functools.partial object
Curt McDowell
report at bugs.python.org
Thu Jun 8 21:12:13 EDT 2017
Curt McDowell added the comment:
There are use cases for this. I hit the problem and eventually wound up here, so I'd like to make a case to re-open.
My project has a callback registry of asyncio handler routines.
register_callback(condition1, handler1)
register_callback(condition2, handler2)
...
I want to register many callbacks, but use only one handler and an argument to differentiate it. I realize our callback systems should provide for a cookie, but it doesn't.
register_callback(condition1, functools.partial(handler, 'detail1'))
register_callback(condition2, functools.partial(handler, 'detail2'))
The callback registry makes sure iscoroutinefunction(handler) because we don't want to defer error checking to the distant future. But iscoroutinefunction() returns False for the partial function. I was hopeful that this might work, but alas, no:
register_callback(condition1,
asyncio.coroutine(functools.partial(handler, 'detail1')))
----------
nosy: +curtmcd
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23519>
_______________________________________
More information about the Python-bugs-list
mailing list