-
-
Notifications
You must be signed in to change notification settings - Fork 178
Accept generator created in Cython #233
Comments
Agreed, I would gladly accept patches. I'm not a Cython user myself so I can't fix this without help. |
Hi @methane, thank you for the link. |
I had already created a CPython ticket for this: https://bugs.python.org/issue24004 Here's what Cython currently (as in "since yesterday") does in order to circumvent the type checks in asyncio and inspect: It's not clear to me what the best fix is here, but my gut feeling tells me that the correct way to deal with this is to create a Generator ABC and do the type checking based on that. A "Generator" is an object that implements the Generator protocol, not necessarily something of type The fact that this crash bug here went unnoticed since Py3.3 makes it obvious, though, that no-one has ever tried this at the C level: |
I think adding For now, how about from abc import ABCMeta, abstractmethod
import types
class Coroutine(metaclass=ABCMeta):
def __iter__(self):
return self
def __next__(self):
raise StopIteration
@abstractmethod
def send(self):
raise StopIteration
Coroutine.register(types.GeneratorType)
Coroutine.register(CoroWrapper)
def iscoroutine(obj):
"""Return True if obj is a coroutine object."""
return isinstance(obj, Coroutine) |
Problem was reported here: https://groups.google.com/forum/#!topic/cython-users/g146SZHxRyM
I think supporting Cython is very important for asyncio performance.
The text was updated successfully, but these errors were encountered: