redis-py asynchronous pubsub

閲覧: 217 回
最初の未読メッセージにスキップ

mrtn

未読、
2015/06/13 4:42:342015/06/13
To: redi...@googlegroups.com

From redis-py's documentation: 

"Behind the scenes, get_message() uses the system's 'select' module to quickly poll the connection's socket. If there's data available to be read, get_message() will read it, format the message and return it or pass it to a message handler. If there's no data to be read, get_message() will immediately return None. This makes it trivial to integrate into an existing event loop inside your application."

And it gives an example:

while True:
    message
= p.get_message()
   
if message:
       
# do something with the message
    time
.sleep(0.001) # be nice to the system :)

In the context of Tornado (which has a main IOLoop thread), how do I utilize get_message() so that redis-py's subscriber operates in an asynchronous fashion? Do I need to register a periodic callback on Tornado's IOLoop such that get_message() polls the connection periodically?

Josiah Carlson

未読、
2015/06/15 14:48:532015/06/15
To: redi...@googlegroups.com
There are clients for Redis that integrate directly into the Tornadio IO loop. That may work better for dealing with pubsub. Here are a couple:

Some Tornado Redis clients:

 - Josiah


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

全員に返信
投稿者に返信
転送
新着メール 0 件