import txredisapi as redis
from twisted.internet import defer, reactor
import config

connection = None

@defer.inlineCallbacks
def run_redis_client(on_started):
    pony = yield redis.makeConnection(config.redis['host'],
                                      config.redis['port'],
                                      config.redis['db'],
                                      poolsize = 8,
                                      reconnect = True,
                                      isLazy = True)
    global connection
    connection = pony
    on_started()


import txredisapi as redis
from twisted.internet import defer, reactor
import config

connection = None

def run_redis_client(on_started):
    df = redis.makeConnection(config.redis['host'],
                              config.redis['port'],
                              config.redis['db'],
                              poolsize = 8,
                              reconnect = True,
                              isLazy = False)
    def done(pony):
        global connection
        connection = pony
        on_started()
    df.addCallback(done)


Fix the Redis client connection to actually work
Fix the Redis client connection to actually work

It previously lied.

  import txredisapi as redis
  from twisted.internet import defer, reactor
  import config
  
  connection = None
  
- @defer.inlineCallbacks
  def run_redis_client(on_started):
-     pony = yield redis.makeConnection(config.redis['host'],
+     df = redis.makeConnection(config.redis['host'],
-                                       config.redis['port'],
+                               config.redis['port'],
-                                       config.redis['db'],
+                               config.redis['db'],
-                                       poolsize = 8,
+                               poolsize = 8,
-                                       reconnect = True,
+                               reconnect = True,
-                                       isLazy = True)
+                               isLazy = False)
+     def done(pony):
-     global connection
+         global connection
-     connection = pony
+         connection = pony
-     on_started()
+         on_started()
+     df.addCallback(done)
  
  
Fix the Redis client connection to actually work
## Code Before:
import txredisapi as redis
from twisted.internet import defer, reactor
import config

connection = None

@defer.inlineCallbacks
def run_redis_client(on_started):
    pony = yield redis.makeConnection(config.redis['host'],
                                      config.redis['port'],
                                      config.redis['db'],
                                      poolsize = 8,
                                      reconnect = True,
                                      isLazy = True)
    global connection
    connection = pony
    on_started()


## Instruction:
Fix the Redis client connection to actually work
## Code After:
import txredisapi as redis
from twisted.internet import defer, reactor
import config

connection = None

def run_redis_client(on_started):
    df = redis.makeConnection(config.redis['host'],
                              config.redis['port'],
                              config.redis['db'],
                              poolsize = 8,
                              reconnect = True,
                              isLazy = False)
    def done(pony):
        global connection
        connection = pony
        on_started()
    df.addCallback(done)

