class_docstr: A shared, distributed Lock. Using Redis for locking allows the Lock
  to be shared across processes and/or machines.
  
  It's left to the user to resolve deadlock issues and make sure
  multiple clients play nicely together.
class_docstr_tok: ["A","shared",",","distributed","Lock",".","Using","Redis","for","locking","allows","the","Lock","to","be","shared","across","processes","and\/or","machines",".","It","'s","left","to","the","user","to","resolve","deadlock","issues","and","make","sure","multiple","clients","play","nicely","together","."]
docstr: Create a new Lock instance named ``name`` using the Redis client
  supplied by ``redis``.
  
  ``timeout`` indicates a maximum life for the lock in seconds.
  By default, it will remain locked until release() is called.
  ``timeout`` can be specified as a float or integer, both representing
  the number of seconds to wait.
  
  ``sleep`` indicates the amount of time to sleep in seconds per loop
  iteration when the lock is in blocking mode and another client is
  currently holding the lock.
  
  ``blocking`` indicates whether calling ``acquire`` should block until
  the lock has been acquired or to fail immediately, causing ``acquire``
  to return False and the lock not being acquired. Defaults to True.
  Note this value can be overridden by passing a ``blocking``
  argument to ``acquire``.
  
  ``blocking_timeout`` indicates the maximum amount of time in seconds to
  spend trying to acquire the lock. A value of ``None`` indicates
  continue trying forever. ``blocking_timeout`` can be specified as a
  float or integer, both representing the number of seconds to wait.
  
  ``thread_local`` indicates whether the lock token is placed in
  thread-local storage. By default, the token is placed in thread local
  storage so that a thread only sees its token, not a token set by
  another thread. Consider the following timeline:
  
      time: 0, thread-1 acquires `my-lock`, with a timeout of 5 seconds.
               thread-1 sets the token to "abc"
      time: 1, thread-2 blocks trying to acquire `my-lock` using the
               Lock instance.
      time: 5, thread-1 has not yet completed. redis expires the lock
               key.
      time: 5, thread-2 acquired `my-lock` now that it's available.
               thread-2 sets the token to "xyz"
      time: 6, thread-1 finishes its work and calls release(). if the
               token is *not* stored in thread local storage, then
               thread-1 would see the token value as "xyz" and would be
               able to successfully release the thread-2's lock.
  
  In some use cases it's necessary to disable thread local storage. For
  example, if you have code where one thread acquires a lock and passes
  that lock instance to a worker thread to release later. If thread
  local storage isn't disabled in this case, the worker thread won't see
  the token set by the thread that acquired the lock. Our assumption
  is that these cases aren't common and as such default to using
  thread local storage.
docstr_tok: ["Create","a","new","Lock","instance","named","``","name","``","using","the","Redis","client","supplied","by","``","redis","``",".","``","timeout","``","indicates","a","maximum","life","for","the","lock","in","seconds",".","By","default",",","it","will","remain","locked","until","release","(",")","is","called",".","``","timeout","``","can","be","specified","as","a","float","or","integer",",","both","representing","the","number","of","seconds","to","wait",".","``","sleep","``","indicates","the","amount","of","time","to","sleep","in","seconds","per","loop","iteration","when","the","lock","is","in","blocking","mode","and","another","client","is","currently","holding","the","lock",".","``","blocking","``","indicates","whether","calling","``","acquire","``","should","block","until","the","lock","has","been","acquired","or","to","fail","immediately",",","causing","``","acquire","``","to","return","False","and","the","lock","not","being","acquired",".","Defaults","to","True",".","Note","this","value","can","be","overridden","by","passing","a","``","blocking","``","argument","to","``","acquire","``",".","``","blocking_timeout","``","indicates","the","maximum","amount","of","time","in","seconds","to","spend","trying","to","acquire","the","lock",".","A","value","of","``","None","``","indicates","continue","trying","forever",".","``","blocking_timeout","``","can","be","specified","as","a","float","or","integer",",","both","representing","the","number","of","seconds","to","wait",".","``","thread_local","``","indicates","whether","the","lock","token","is","placed","in","thread-local","storage",".","By","default",",","the","token","is","placed","in","thread","local","storage","so","that","a","thread","only","sees","its","token",",","not","a","token","set","by","another","thread",".","Consider","the","following","timeline",":","time",":","0",",","thread-1","acquires","`","my-lock","`",",","with","a","timeout","of","5","seconds",".","thread-1","sets","the","token","to","``","abc","''","time",":","1",",","thread-2","blocks","trying","to","acquire","`","my-lock","`","using","the","Lock","instance",".","time",":","5",",","thread-1","has","not","yet","completed",".","redis","expires","the","lock","key",".","time",":","5",",","thread-2","acquired","`","my-lock","`","now","that","it","'s","available",".","thread-2","sets","the","token","to","``","xyz","''","time",":","6",",","thread-1","finishes","its","work","and","calls","release","(",")",".","if","the","token","is","*","not","*","stored","in","thread","local","storage",",","then","thread-1","would","see","the","token","value","as","``","xyz","''","and","would","be","able","to","successfully","release","the","thread-2","'s","lock",".","In","some","use","cases","it","'s","necessary","to","disable","thread","local","storage",".","For","example",",","if","you","have","code","where","one","thread","acquires","a","lock","and","passes","that","lock","instance","to","a","worker","thread","to","release","later",".","If","thread","local","storage","is","n't","disabled","in","this","case",",","the","worker","thread","wo","n't","see","the","token","set","by","the","thread","that","acquired","the","lock",".","Our","assumption","is","that","these","cases","are","n't","common","and","as","such","default","to","using","thread","local","storage","."]
code: def __init__(
      self,
      redis: Union["Redis", "RedisCluster"],
      name: Union[str, bytes, memoryview],
      timeout: Optional[float] = None,
      sleep: float = 0.1,
      blocking: bool = True,
      blocking_timeout: Optional[float] = None,
      thread_local: bool = True,
  ):
      """
      Create a new Lock instance named ``name`` using the Redis client
      supplied by ``redis``.
  
      ``timeout`` indicates a maximum life for the lock in seconds.
      By default, it will remain locked until release() is called.
      ``timeout`` can be specified as a float or integer, both representing
      the number of seconds to wait.
  
      ``sleep`` indicates the amount of time to sleep in seconds per loop
      iteration when the lock is in blocking mode and another client is
      currently holding the lock.
  
      ``blocking`` indicates whether calling ``acquire`` should block until
      the lock has been acquired or to fail immediately, causing ``acquire``
      to return False and the lock not being acquired. Defaults to True.
      Note this value can be overridden by passing a ``blocking``
      argument to ``acquire``.
  
      ``blocking_timeout`` indicates the maximum amount of time in seconds to
      spend trying to acquire the lock. A value of ``None`` indicates
      continue trying forever. ``blocking_timeout`` can be specified as a
      float or integer, both representing the number of seconds to wait.
  
      ``thread_local`` indicates whether the lock token is placed in
      thread-local storage. By default, the token is placed in thread local
      storage so that a thread only sees its token, not a token set by
      another thread. Consider the following timeline:
  
          time: 0, thread-1 acquires `my-lock`, with a timeout of 5 seconds.
                   thread-1 sets the token to "abc"
          time: 1, thread-2 blocks trying to acquire `my-lock` using the
                   Lock instance.
          time: 5, thread-1 has not yet completed. redis expires the lock
                   key.
          time: 5, thread-2 acquired `my-lock` now that it's available.
                   thread-2 sets the token to "xyz"
          time: 6, thread-1 finishes its work and calls release(). if the
                   token is *not* stored in thread local storage, then
                   thread-1 would see the token value as "xyz" and would be
                   able to successfully release the thread-2's lock.
  
      In some use cases it's necessary to disable thread local storage. For
      example, if you have code where one thread acquires a lock and passes
      that lock instance to a worker thread to release later. If thread
      local storage isn't disabled in this case, the worker thread won't see
      the token set by the thread that acquired the lock. Our assumption
      is that these cases aren't common and as such default to using
      thread local storage.
      """
      self.redis = redis
      self.name = name
      self.timeout = timeout
      self.sleep = sleep
      self.blocking = blocking
      self.blocking_timeout = blocking_timeout
      self.thread_local = bool(thread_local)
      self.local = (
          threading.local() if self.thread_local else SimpleNamespace()
      )
      self.local.token = None
      self.register_scripts()
  
file_path: catboost/contrib/python/redis/py3/redis/asyncio/lock.py
imports: import asyncio
  import threading
  import uuid
  from types import SimpleNamespace
  from typing import TYPE_CHECKING, Awaitable, Optional, Union
  from redis.exceptions import LockError, LockNotOwnedError
label_desc: Use image node_id 1 to create a new Lock object  with example: obj = Lock(redis, name, timeout, sleep, blocking, blocking_timeout, thread_local)