Theron Luhn added the comment:
For me, the context is a test I was writing that went something like this:
>>> import asyncio
>>> from unittest.mock import Mock
>>> loop = asyncio.get_event_loop()
>>> blocking_func = Mock()
>>> loop.run_in_executor(None, blocking_func)
Traceback (most recent call last):
File "", line 1, in
File
"/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py",
line 497, in run_in_executor
raise TypeError("coroutines cannot be used with run_in_executor()")
TypeError: coroutines cannot be used with run_in_executor()
I understand that the nature of Mock makes its behaviors ambiguous. However,
there are a few reasons I think asyncio.iscoroutinefunction(Mock()) should be
false:
1) inspect.iscoroutinefunction reports false. asyncio.iscoroutinefunction
should be consistent with this.
2) A coroutine function should return a coroutine object. Mock's default
behavior won't return a coroutine object, so it shouldn't be identified as a
coroutine function by default.
3) It's tidier to make a non-coroutine function Mock into a coroutine function
(asyncio.coroutine(Mock())) than it is to make a coroutine function Mock into a
non-coroutine function Mock (mock._is_coroutine is implementation-specific
hack).
--
___
Python tracker
<http://bugs.python.org/issue25599>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com