I tried following the chat demo a bit closer and came up with this.
class ThingThatBlocks:
@classmethod
def block_things(cls, callback):
logging.debug('going to sleep for 30 seconds')
sleep(30)
callback('did i block you too much?')
class SampleConnection(tornadio.SocketConnection):
@tornado.web.asynchronous
def on_message(self, message):
if message['action'] == 'blocking':
ThingThatBlocks.block_things(self.async_callback(self.on_async_response))
else:
self.send(message)
def on_async_response(self, message):
self.send(message)
Unfortunately this still completely blocks the server i.e. I can't
send and receive messages through the websocket while the async method
is running.