Python Tornado - How to Implement Long-Polling Server to Read from a Queue
问题 I'm trying to build a web server to collect "commands" via AJAX and then distribute the commands to clients via long-polling. The goal is that someone POSTs some data to /add-command. Another client implements a long-polling client hitting /poll waiting for a command to execute. I think a queue is the right data structure to use to hold commands waiting for attention. I'd like the commands to essentially be distributed immediately to any long-polling client but held if no client is currently