wamd
wamd copied to clipboard
Is there a guide for the library to run parallel?
could you explain in more detail?
Let's say I have five messages that process messages simultaneously without having to wait for the previous one to be processed
Twisted is an event driven networking engine and provide a deferred that hold an eventual result much like Promise or Future.
connection.relayMessage
return a deferred that fired with the message instance you send
so you can send more than one message at once and wait for their results like so:
from twisted.internet import defer
deferredLIst = []
for mesage in messages:
d = connection.relayMessage(message)
deferredList.append(d)
deferred = defer.gatherResults(deferredList)
def onResults(results):
print(results)
deferred.addCallback(onResults)
How to send message with scheduler, eg celery or redis queue