leporo / tornado-redis

Asynchronous Redis client that works within Tornado IO loop.
667 stars 163 forks source link

"SELECT" command in pipeline #37

Closed dnox closed 11 years ago

dnox commented 11 years ago

I have tornado app with redis connect:

class Application(tornado.web.Application):
    def __init__(self):
        self.client = tornadoredis.Client(selected_db=self.config.get('redis', 'db'),
                                          password=self.config.get('redis', 'password'),)
        self.client.connect()

And i have request handler, that use pipeline:

pipe = self.application.client.pipeline()

pipe.smembers('%s_unmoderated' % self.current_user)
pipe.smembers('%s_moderated' % self.current_user)
pipe.smembers('%s_templates' % self.current_user)

print pipe.command_stack
res = [a for a in (yield tornado.gen.Task(pipe.execute))]
print pipe.command_stack

First print: [SMEMBERS(('test_unmoderated',),{'callback': None}), SMEMBERS(('test_moderated',),{'callback': None}), SMEMBERS(('test_templates',),{'callback': None})]

Second print: [SELECT(('4',),{'callback': <tornado.stack_context._StackContextWrapper object at 0x1eafaf8>})]

Thus, on second function call my res contains 4 elements instead of 3.

leporo commented 11 years ago

Do you use the latest tornado-redis revision? Please check if your report is not a duplicate of #35 or an issue is still persist.

dnox commented 11 years ago

Yeah, sorry. Had 2.4.1. 2.4.2 works fine.

leporo commented 11 years ago

Thank you.

Please check this note: https://github.com/leporo/tornado-redis#tornado-redis-vs-redis-py

I would like to suggest you checking if your code may be re-implemented using the redis-py client and to benchmark both implementations. May be you don't need tornado-redis connection pooling at all in this particular case.