Reputation: 1403
I have an idea. Write a WebSocket based RPC that would process messages according to the scenario below.
NOTE: the key point is that the WS server should be non-blocking and responsible only for:
NOTE2: it might be a good idea to store client identifier somehow and pass it around with the message from the client
NOTE3: it is completely fine that because of queueing the messages back and forth the speed of simple message processing (e.g. get message as input and push it back as a result) shall become lower. Target goal is to be able to run processor expensive operations (rough non-practical example: several nested “for” loops) in the pool with the same code style as handling fast messages. I.e. pop message from the input queue together with some sort of client identifier, process it (might take a while) and push the processing results together with client ID to the output queue.
Questions:
Acknowledgments:
Upvotes: 3
Views: 2379
Reputation: 34292
Tornado's IOLoop
allows you handling events from any file object by its file descriptor, so you could try this:
multiprocessing.Pipe
add_handler
for each pipe's parent end (using the connection's fileno()
)multiprocessing.Queue
of any MQ.Upvotes: 1