Skip to content

Commit

Permalink
Caffeination: Assert caffeine count never falls below zero
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfstr committed Aug 31, 2023
1 parent d9ab5b8 commit 0e4cc00
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/crystal/util/caffeination.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def add_caffeine(cls) -> None:
def remove_caffeine(cls) -> None:
with cls._lock:
cls._caffeine_count -= 1
assert cls._caffeine_count >= 0
new_caffeine_count = cls._caffeine_count # capture
if new_caffeine_count == 0:
cls._set_caffeinated(False)
Expand Down

0 comments on commit 0e4cc00

Please sign in to comment.