[Twisted-Python] Looping in a deffered
John Joske
jjoske at nextdigital.com
Fri Sep 4 22:49:39 EDT 2009
I'm trying to make a simple deferred that will continue get a message of
a message queue, process it and then wait for another message.
While I can get the first message easily I am unable to work out how I
can get a second message without creating a new deferred in the printMsg
function, which eventually gives me a maximum recursion depth exceeded.
Basic code is a follows:
from twisted.internet import reactor,defer
def printMsg(msg):
print "Message is:"
print msg
deferred=getMsg()
deferred.addCallback(printMsg)
def getMsg() :
d=defer.Deferred()
#replaced with code that actually goes to a queue to get the message
msg="This is a message"
d.callback(msg)
return d
deferred=getMsg()
deferred.addCallback(printMsg)
reactor.run()
Can any one point me on the right path to solve this?
Thanks
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090905/3277bb8d/attachment.htm
More information about the Twisted-Python
mailing list