Monday, March 1, 2010

created a defered function

def Normal(args):
def startMessages():
for key in sendMSGSequence:
self.deferQueue.put(key)
sleep(1) # simulate like a real GUI serial Connection.
#print key
reactor.callLater(1, startMessages)

The inner function will execute after 1 second callback from the reactor function. The Reactor is continue is execution with being block.

1 comment:

  1. This method is not asynchronous, I was wrong!!!
    Please use:
    d = threads.deferToThread(startMessages)
    d.addCallback(somefunction)

    This will create a defered thread make the event non-blocking.

    ReplyDelete