1717from servicelib import redis as servicelib_redis
1818from servicelib .redis import (
1919 CouldNotAcquireLockError ,
20+ LockLostError ,
2021 RedisClientSDK ,
2122 RedisClientsManager ,
2223 RedisManagerDBConfig ,
3536]
3637
3738pytest_simcore_ops_services_selection = [
38- # "redis-commander",
39+ "redis-commander" ,
3940]
4041
4142
@@ -48,7 +49,7 @@ async def _is_locked(redis_client_sdk: RedisClientSDK, lock_name: str) -> bool:
4849async def redis_client_sdk (
4950 get_redis_client_sdk : Callable [
5051 [RedisDatabase ], AbstractAsyncContextManager [RedisClientSDK ]
51- ]
52+ ],
5253) -> AsyncIterator [RedisClientSDK ]:
5354 async with get_redis_client_sdk (RedisDatabase .RESOURCES ) as client :
5455 yield client
@@ -165,6 +166,23 @@ async def test_lock_context(
165166 assert await ttl_lock .owned () is False
166167
167168
169+ async def test_issue_cannot_acquire_lock_anymore (
170+ redis_client_sdk : RedisClientSDK , faker : Faker
171+ ):
172+ lock_name = faker .pystr ()
173+ with pytest .raises (LockLostError ):
174+ async with redis_client_sdk .lock_context (lock_name ) as ttl_lock :
175+ assert await _is_locked (redis_client_sdk , lock_name ) is True
176+ assert await ttl_lock .owned () is True
177+ # let's force release the lock
178+ await redis_client_sdk ._client .delete (lock_name )
179+
180+ await asyncio .sleep (20 )
181+ # assert await _is_locked(redis_client_sdk, lock_name) is False
182+ # assert await ttl_lock.owned() is False
183+ # actually it should even raise here
184+
185+
168186async def test_lock_context_with_already_locked_lock_raises (
169187 redis_client_sdk : RedisClientSDK , faker : Faker
170188):
@@ -272,7 +290,6 @@ async def _inc_counter() -> None:
272290async def test_redis_client_sdks_manager (
273291 mock_redis_socket_timeout : None , redis_service : RedisSettings
274292):
275-
276293 all_redis_configs : set [RedisManagerDBConfig ] = {
277294 RedisManagerDBConfig (db ) for db in RedisDatabase
278295 }
0 commit comments