(self)
return await self._pool
Get an connection for the self instance
Get an connection for the self instance
Get an connection for the self instance
async def connect(self):
        """
        Get an connection for the self instance
        """
        address, redis_kwargs = (), {}

        if isinstance(self.connection, Sentinel):
            self._pool = await self.connection.get_master()
        elif isinstance(self.connection, dict):
            # a dict like {'host': 'localhost', 'port': 6379,
            #              'db': 0, 'password': 'pass'}
            kwargs = self.connection.copy()
            address = (
                kwargs.pop('host', 'localhost'),
                kwargs.pop('port', 6379)
            )
            redis_kwargs = kwargs
        elif isinstance(self.connection, aioredis.Redis):
            self._pool = self.connection
        else:
            # a tuple or list ('localhost', 6379)
            # a string "redis://host:6379/0?encoding=utf-8" or
            # a unix domain socket path "/path/to/redis.sock"
            address = self.connection

        if self._pool is None:
            if 'minsize' not in redis_kwargs:
                redis_kwargs['minsize'] = 1
            if 'maxsize' not in redis_kwargs:
                redis_kwargs['maxsize'] = 100
            async with self._lock:
                if self._pool is None:
                    self.log.debug('Connecting %s', repr(self))
                    self._pool = await self._create_redis_pool(address, **redis_kwargs)

        if self.set_lock_script_sha1 is None or self.unset_lock_script_sha1 is None:
            with await self._pool as redis:
                await self._register_scripts(redis)

        return await self._pool
async def connect ( self ) : address , redis_kwargs = ( ) , { } if isinstance ( self . connection , Sentinel ) : self . _pool = await self . connection . get_master ( ) elif isinstance ( self . connection , dict ) : # a dict like {'host': 'localhost', 'port': 6379, #              'db': 0, 'password': 'pass'} kwargs = self . connection . copy ( ) address = ( kwargs . pop ( 'host' , 'localhost' ) , kwargs . pop ( 'port' , 6379 ) ) redis_kwargs = kwargs elif isinstance ( self . connection , aioredis . Redis ) : self . _pool = self . connection else : # a tuple or list ('localhost', 6379) # a string "redis://host:6379/0?encoding=utf-8" or # a unix domain socket path "/path/to/redis.sock" address = self . connection if self . _pool is None : if 'minsize' not in redis_kwargs : redis_kwargs [ 'minsize' ] = 1 if 'maxsize' not in redis_kwargs : redis_kwargs [ 'maxsize' ] = 100 async with self . _lock : if self . _pool is None : self . log . debug ( 'Connecting %s' , repr ( self ) ) self . _pool = await self . _create_redis_pool ( address , * * redis_kwargs ) if self . set_lock_script_sha1 is None or self . unset_lock_script_sha1 is None : with await self . _pool as redis : await self . _register_scripts ( redis ) return await self . _pool