Error: Types.coroutine() Expects A Callable
I have the following class: from tornado import gen class VertexSync(Vertex): @wait_till_complete @gen.coroutine @classmethod def find_by_value(cls, *args, **kwarg
Solution 1:
The problem is that classmethod
does... interesting things. Once the class definition has finished you have a nice callable method on the class, but during the definition you have a classmethod object
, which isn't callable:
>>> a = classmethod(lambda self: None)
>>> a
<classmethod object at 0x10b46b390>
>>> callable(a)
False
>>> a()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'classmethod' object is not callable
The simplest fix is to re-order the decorators, so that rather than trying to turn a classmethod into a coroutine:
@gen.coroutine
@classmethod
def thing(...):
...
you are trying to turn a coroutine into a classmethod:
@classmethod
@gen.coroutine
def thing(...):
...
Note that the decorators are applied "inside out", see e.g. Decorator execution order
Post a Comment for "Error: Types.coroutine() Expects A Callable"