Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yield blockd if the connection fails #81

Open
yorkshireandrew opened this issue May 20, 2015 · 2 comments
Open

yield blockd if the connection fails #81

yorkshireandrew opened this issue May 20, 2015 · 2 comments

Comments

@yorkshireandrew
Copy link

With the code below when __testRedis is called after __establishConnectionPool where an invalid host/port configuration is used only the 'now' time is printed, print x is never reached.

@staticmethod
def sleep(duration):
    d = defer.Deferred()
    reactor.callLater(duration, lambda *ign: d.callback(None))
    return d

@defer.inlineCallbacks
def __establishConnectionPool(self, config):
    redisConfig = config['redis']
    self.redisConnection = yield txredisapi.lazyConnectionPool(host=redisConfig['host'], port=int(redisConfig['port']), reconnect=True)

@defer.inlineCallbacks
def __testRedis(self):
    self.sleep(5)
    try:
        now = time.time()
        print now
        yield self.redisConnection.set('testme', now)
        x = yield self.redisConnection.get('testme')
        print x
        if x != now:
            raise Exception('Redis dead')
    except Exception as e:
        print "Exception: %s" % str(e)
    finally:
        try:
            yield self.redisConnection.disconnect()
        except Exception:
            pass
@yorkshireandrew
Copy link
Author

Ah my self.sleep(5) in __testRedis should be yield self.sleep(5) stlll need to validate if there is still an issue

@dpkp
Copy link
Contributor

dpkp commented Jun 30, 2015

were you testing against master or the 1.2 release ? if master (or v1.3), the call would probably block on getConnection. see #68 . You might try the same test w/ reconnect=False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants