def count_down(self):
with self._lock:
assert self._count > 0
self._count -= 1
# Return inside lock to return the correct value,
# otherwise another thread could already have
# decremented again.
return self._count