fixing tornadoserver thread safety bug: ensuring write_message is called inside the ioloop
merge