code: def acquire_restore(lock, state):
      
      if hasattr(lock, '_acquire_restore'):
          lock._acquire_restore(state)
      elif hasattr(lock, 'acquire'):
          lock.acquire()
      else:
          raise TypeError('expecting Lock/RLock')
docs: Acquire a lock and restore its state.