def release(self):
    self.__lock.acquire()
    try:
      assert self.__is_exclusive() or self.__is_sharer(), \
        "Cannot release non-owned lock"

      # Autodetect release type
      if self.__is_exclusive():
        self.__exc = None
        notify = True
      else:
        self.__shr.remove(threading.currentThread())
        notify = not self.__shr

      # Notify topmost condition in queue if there are no owners left (for
      # shared locks)
      if notify:
        self.__notify_topmost()
    finally:
      self.__lock.release()
Test for protocol negotiation
dataset/ETHPy150Open ganeti/ganeti/lib/locking.py/SharedLock.release--crossover with--dataset/ETHPy150Open datastax/python-driver/tests/integration/standard/test_cluster.py/ClusterTests.test_protocol_negotiation