code: def is_locked(lock):
      
      if hasattr(lock, 'locked'):
          return lock.locked()
      elif hasattr(lock, '_is_owned'):
          return lock._is_owned()
      else:
          raise TypeError('expecting Lock/RLock')
docs: Return whether a lock is locked.
  
      Suppors :class:`Lock`, :class:`RLock`, :class:`threading.Lock` and
      :class:`threading.RLock` instances.