Search code examples
tornado

Tornado blocks when I try and save to MongoDB


I was trying to make a web spider via tornado. I want to save the comments to my disk or database. What should I use to make these process quickly?

Everything seems block when I try to save file,even though I use gen.coroutine. Data base is MongoDB


Solution

  • When using Tornado, if you do not want Tornado to block while you are communicating with third party services you need to use an asynchronous library. There is a list of asynchronous libraries for Tornado here:

    https://github.com/tornadoweb/tornado/wiki/Links

    For your specific need you will want to look at these libraries for Mongo: