import stackless
class MyTasklet(stackless.tasklet):
def __init__(self, func, msg):
pass
def foo():
pass
msg = 'hello'
MyTasklet(foo, msg)()
I am using stackless python
, this code generates the following error:
Traceback (most recent call last):
File "E:/workspace/python/test/klass.py", line 11, in <module>
MyTasklet(foo, msg)()
TypeError: tasklet() takes at most 1 argument (2 given)
It's very odd since I did not call the constructor of stackless.tasklet
.
Anyone know what exactly the error is about.
Since the problem has to do with sub-classing
stackless.tasklet
, you could just makeMyTasklet
a callableobject
instead like follows:EDIT: Alternatively you can just override
__new__
to pass the correct arguments tostackless.tasklet.__new__
: