def METHOD_NAME(self, wants_write):
    waiter = Waiter(wants_write)
    self._waiters.append(waiter)
    try:
        self._lock.release()
        try:
            waiter.wait()
        finally:
            self._lock.acquire()
    finally:
        self._waiters.remove(waiter)