multithreading - Python Twisted TCP application - How to prevent incoming message loss by blocking process -


i have 10 messages/second(total activity) coming in on tcp 40 clients. need take each message , 5 second process (look webservice, db queries , write results db).

how separate messages coming in slow 5 second process? might receive message client while processing message client. never want lose message.

with twisted, answer want do:

from twisted.python.log import err twisted.internet.protocol import protocol  class yourprotocol(protocol):     ...     def messagereceived(self, message):         d = lookupwebservice(message)         d.addcallback(querydatabase)         d.addcallback(saveresults)         d.adderrback(err, "servicing %r failed" % (message,)) 

you can find apis interacting web services in twisted.web.client (presuming "web services" things talk using http client). can find apis interacting sql database servers in twisted.enterprise.adbapi. can find apis interacting other kinds of databases little googling.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -