def __enter__(self):
    if (self._port is None):
        self.port = get_random_port()
    else:
        self.port = self._port
    args = ([self.path, '--port', str(self.port), '--dir', tempfile.gettempdir(), '--save', ''] + self.extra_args)
    self.process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=open(os.devnull, 'w'))
    while True:
        try:
            self.client().ping()
            break
        except redis.ConnectionError:
            self.process.poll()
            if (self.process.returncode is not None):
                raise RuntimeError('Process has exited')
            time.sleep(0.1)
    return self.client()
def __enter__(self):
    if (self._port is None):
        self.port = get_random_port()
    else:
        self.port = self._port
    args = ([self.path, '--port', str(self.port), '--dir', tempfile.gettempdir(), '--save', ] + self.extra_args)
    self.process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=open(os.devnull, 'w'))
    while True:
        try:
            self.client().ping()
            break
        except redis.ConnectionError:
            self.process.poll()
            if (self.process.returncode is not None):
                raise RuntimeError('Process has exited')
            time.sleep(0.1)
    return self.client()