[Twisted-Python] Newbie question
Hi, I thought I'd better try and understand twisted a bit more rather than just using it! Can anyone tell me why this code is erroneous? ##################### from twisted.internet import reactor, defer print "test" def printResult(s): print "Data: %s", str(s) def printEnd(): print "End" def printError(error): print error d = defer.Deferred() reactor.callLater(4, d.callback) d.addCallback(printEnd) d.addErrback(printError) reactor.run() ################################### I get the error: TypeError: callback() takes exactly two arguments (1 given) in twisted/internet/base.py call.func(*call.args, **call.kw) Thanks Simon -- Linux user #458601 - http://counter.li.org.
Hi, try exactly what it says, that is, supply callback with an argument: example: result = 'I'm the result' reactor.callLater(4, d.callback, result) Then it should do. Petr Simon Pickles napsal(a):
Hi,
I thought I'd better try and understand twisted a bit more rather than just using it!
Can anyone tell me why this code is erroneous?
##################### from twisted.internet import reactor, defer
print "test"
def printResult(s): print "Data: %s", str(s)
def printEnd(): print "End"
def printError(error): print error
d = defer.Deferred()
reactor.callLater(4, d.callback) d.addCallback(printEnd) d.addErrback(printError)
reactor.run() ################################### I get the error:
TypeError: callback() takes exactly two arguments (1 given) in twisted/internet/base.py call.func(*call.args, **call.kw)
Thanks
Simon
UGHHH, Thunderbird's syntax coloring sucks ;) of course read that result = "I'm the result" Otherwise, look at: http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.I... especially look at the possible args and kwargs arguments and it'll give you a delayedCall: http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.I... Petr Petr Mifek napsal(a):
Hi,
try exactly what it says, that is, supply callback with an argument:
example:
result = 'I'm the result' reactor.callLater(4, d.callback, result)
Then it should do.
Petr
Simon Pickles napsal(a):
Hi,
I thought I'd better try and understand twisted a bit more rather than just using it!
Can anyone tell me why this code is erroneous?
##################### from twisted.internet import reactor, defer
print "test"
def printResult(s): print "Data: %s", str(s)
def printEnd(): print "End"
def printError(error): print error
d = defer.Deferred()
reactor.callLater(4, d.callback) d.addCallback(printEnd) d.addErrback(printError)
reactor.run() ################################### I get the error:
TypeError: callback() takes exactly two arguments (1 given) in twisted/internet/base.py call.func(*call.args, **call.kw)
Thanks
Simon
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Jan 24, 2008 2:33 PM, Simon Pickles <sipickles@hotmail.com> wrote:
Hi,
I thought I'd better try and understand twisted a bit more rather than just using it!
Can anyone tell me why this code is erroneous?
##################### ... reactor.callLater(4, d.callback) ... ################################### I get the error:
TypeError: callback() takes exactly two arguments (1 given) in twisted/internet/base.py call.func(*call.args, **call.kw)
d.callback needs an argument. You're not passing one. Try: reactor.callLater(4, d.callback, "whatever") -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/
participants (3)
-
Christopher Armstrong
-
Petr Mifek
-
Simon Pickles