leporo / tornado-redis

Asynchronous Redis client that works within Tornado IO loop.
666 stars 162 forks source link

Note about 'client.listen' #67

Closed JackyChou closed 10 years ago

JackyChou commented 10 years ago

When I use 'subscribe' and 'psubscribe' with Python2.7,there is someting wrong. My code look like:

def handle_message(msg):
    print 'hello world'
yield gen.Task(client.subscribe, 'channel_one')
yield gen.Task(client.psubscribe, 'channel_two'+'/*')
client.listen(handle_message)

But this code can't triggers the callback function when it received message. Then I delete the code

callback = None

in 'client._subscribe' .Then it works well.

JackyChou commented 10 years ago

Now I use this code:

def handle_message(msg):
    print 'hello world'
yield gen.Task(client.subscribe, 'channel_one')
client.listen(handle_message)
yield gen.Task(client.psubscribe, 'channel_two'+'/*')

it works well. I should call listen afrer call subscribe or psubscribe at the first time.