How to run functions outside websocket loop in python (tornado)

后端 未结 3 1245
[愿得一人]
[愿得一人] 2020-12-08 00:52

I\'m trying to set up a small example of a public Twitter stream over websockets. This is my websocket.py, and it\'s working.

What I\'m wondering is: how can I inte

3条回答
  •  眼角桃花
    2020-12-08 01:18

    One way to also do this is to use a pub-sub module.

    Meaning you have your connections subscribe to it, and rather than setting timeouts for every single connection, you just set one timeout to publish after said period of time.

    Probably one of the most implemented is redis. There are also some modules specifically for tornado: toredis or brükva for example.

    Of course this might not be necessary for just a simple page, but scales really well and is also very nice to maintain/extend once you've set it up.

提交回复
热议问题