code: def thread_lock(lock):
      
      if hasattr(lock, '_lock'):
          return lock._lock
      elif hasattr(lock, 'acquire'):
          return lock
      else:
          raise TypeError('expecting Lock/RLock')
docs: Return the thread lock for *lock*.