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

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to