Skip to content Skip to sidebar Skip to footer

Making Tornado Websocket Handler Thread Safe

I am randomly getting error 1006 ( (I failed the WebSocket connection by dropping the TCP connection) when trying to write messages from threads using Tornado's websocket server ha

Solution 1:

Tornado is based on a single-threaded event loop; all interactions with Tornado objects must be on the event loop's thread. Use IOLoop.current().add_callback() from another thread when you need to transfer control back to the event loop.

See also http://www.tornadoweb.org/en/stable/web.html#thread-safety-notes

Post a Comment for "Making Tornado Websocket Handler Thread Safe"