我试图理解这个使用 Gevent 和 Redis pub/sub 的 socket.io 代码。显然,该subscribe方法等待通道上的消息。
我可以拥有(数以万计)数千个频道,每个频道一个用于向一个用户推送通知和聊天?频道是为此而设计的吗?
def _sub_listener(socketio, chan):
"""
This is the method that will block and listen
for new messages to be published to redis, since
we are using coroutines this method can block on
listen() without interrupting the rest of the site
"""
red = Redis(REDIS_HOST)
red.subscribe(chan)
for i in red.listen():
socketio.send({'message': i})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
615 次 |
| 最近记录: |