How to use the aioredlock.redis.Instance function in aioredlock

To help you get started, we’ve selected a few aioredlock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joanvila / aioredlock / tests / ut / test_redis.py View on Github external
def test_initialization(self):

        instance = Instance(('localhost', 6379))

        assert instance.connection == ('localhost', 6379)
        assert instance._pool is None
        assert isinstance(instance._lock, asyncio.Lock)
github joanvila / aioredlock / tests / ut / test_redis.py View on Github external
async def test_connect_pool_not_created(self, connection, address, redis_kwargs):
        with patch('aioredlock.redis.Instance._create_redis_pool') as \
                create_redis_pool:

            fake_pool = FakePool()
            create_redis_pool.side_effect = fake_create_redis_pool(fake_pool)
            instance = Instance(connection)

            assert instance._pool is None
            pool = await instance.connect()

            create_redis_pool.assert_called_once_with(
                address, **redis_kwargs,
                minsize=1, maxsize=100)
            assert pool is fake_pool
            assert instance._pool is fake_pool
github joanvila / aioredlock / tests / ut / test_redis.py View on Github external
def fake_instance(self):
        with patch('aioredlock.redis.Instance._create_redis_pool') as \
                create_redis_pool:
            fake_pool = FakePool()
            create_redis_pool.side_effect = fake_create_redis_pool(fake_pool)
            instance = Instance(('localhost', 6379))
            yield instance
github joanvila / aioredlock / tests / ut / test_redis.py View on Github external
async def test_connect_pool_already_created(self):

        with patch('aioredlock.redis.Instance._create_redis_pool') as \
                create_redis_pool:
            instance = Instance(('localhost', 6379))
            fake_pool = FakePool()
            instance._pool = fake_pool

            pool = await instance.connect()

            assert not create_redis_pool.called
            assert pool is fake_pool
github joanvila / aioredlock / tests / ut / test_redis.py View on Github external
async def test_connect_pool_aioredis_instance(self):
        with patch('aioredlock.redis.Instance._create_redis_pool') as \
                create_redis_pool:
            redis_connection = await aioredis.create_redis_pool('redis://localhost')
            instance = Instance(redis_connection)

            await instance.connect()
            assert not create_redis_pool.called
github joanvila / aioredlock / aioredlock / redis.py View on Github external
def __init__(self, redis_connections):

        self.instances = []
        for connection in redis_connections:
            self.instances.append(Instance(connection))

aioredlock

Asyncio implemetation of Redis distributed locks

MIT
Latest version published 2 years ago

Package Health Score

60 / 100
Full package analysis

Similar packages