Skip to content

New connection created everytime #504

@JohnSundarraj

Description

@JohnSundarraj

Hi there, i'm trying to use RQ worker to execute background jobs in my Torando App. I'm successful sofar, but one weird thing i noticed. Redis client creates a new connection everytime a job gets executed by the RQ worker. I found this issue by using the command redis-cli info | grep 'connection'. Everytime i check this command after a job gets executed, its incremented. To solve this problem i tried various implementations, but nothing worked. Below it he wrapper class i've created. It seems to be a bug in redis client, if i'm not wrong...Need help on this issue. Thanks in advance.

# Redis controller.
class Redis(object):
  __Instance = None

  def __init__(self):
    if self.__class__.__Instance:
      return
    else:
      self.__class__.__Instance = self
    self.Conf = DBConf()['Redis']
    print "NEW REDIS"
    self.Engine = redis.Redis(connection_pool=redis.ConnectionPool(host=self.Conf['Host'],port=self.Conf['Port'],max_connections=10))

  def __new__(self):
    if self.__Instance:
      return self.__Instance
    else:
      return object.__new__(self)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions