code: def test_redis_lock_context():
      channel = str(random.random())
  
      lock_a = redis.RedisLock(channel, fail_when_locked=True)
      with lock_a:
          time.sleep(0.01)
          lock_b = redis.RedisLock(channel, fail_when_locked=True)
          with pytest.raises(portalocker.AlreadyLocked):
              with lock_b:
                  pass
  
file_path: catboost/contrib/python/portalocker/py3/tests/test_redis.py
imports: import _thread
  import logging
  import random
  import time
  import pytest
  from redis import client
  from redis import exceptions
  import portalocker
  from portalocker import redis
  from portalocker import utils
label_desc: Use image node_id 4 for calling a global function with example usage: test_redis_lock_context() without return types