leporo / tornado-redis

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

Sequential subscribe problem #79

Open FZambia opened 9 years ago

FZambia commented 9 years ago

Hello!

Consider this test case:

class SequentialPubSubTestCase(RedisTestCase):

    def setUp(self):
        super(SequentialPubSubTestCase, self).setUp()
        self.subscriber = self._new_client()

    def tearDown(self):
        try:
            self.subscriber.connection.disconnect()
            del self.subscriber
        except AttributeError:
            pass
        super(SequentialPubSubTestCase, self).tearDown()

    @async_test
    @gen.engine
    def test_sequential_subscribe(self):
        yield gen.Task(self.subscriber.subscribe, 'test.channel')
        yield gen.Task(self.subscriber.subscribe, 'test.channel2')
        self.assertTrue(bool(self.subscriber.subscribed))

When I run it - the second subcription doesn't not yield to the caller and test case hangs until timeout:

(env)MacAir:tornado-redis fz$ python -m tornado.testing tornadoredis.tests.test_pubsub.SequentialPubSubTestCase
F
======================================================================
FAIL: test_sequential_subscribe (tornadoredis.tests.test_pubsub.SequentialPubSubTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/www/different/python/centrifuge/env/lib/python2.7/site-packages/tornado/testing.py", line 118, in __call__
    result = self.orig_method(*args, **kwargs)
  File "tornadoredis/tests/redistest.py", line 21, in _runner
    return self.wait(timeout=timeout)
  File "/private/var/www/different/python/centrifuge/env/lib/python2.7/site-packages/tornado/testing.py", line 312, in wait
    self.__rethrow()
  File "/private/var/www/different/python/centrifuge/env/lib/python2.7/site-packages/tornado/testing.py", line 248, in __rethrow
    raise_exc_info(failure)
  File "/private/var/www/different/python/centrifuge/env/lib/python2.7/site-packages/tornado/testing.py", line 296, in timeout_func
    timeout)
AssertionError: Async operation timed out after 5 seconds

----------------------------------------------------------------------
Ran 1 test in 5.011s

FAILED (failures=1)
[E 141025 13:00:12 testing:687] FAIL
leporo commented 9 years ago

Thank you. I added your test to PubSubTestCase. And yes, it fails :(