Skip to content

Commit b9a7c04

Browse files
committed
Fixed a missed lock in safe bank global-style.
1 parent e281518 commit b9a7c04

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/06-thread-safety/safe_bank.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def do_transfer(from_account: Account, to_account: Account, amount: int):
7979

8080

8181
def validate_bank(accounts: List[Account], total: int, quiet=False):
82-
current = sum(a.balance for a in accounts)
82+
with transfer_lock:
83+
current = sum(a.balance for a in accounts)
84+
8385
if current != total:
8486
print("ERROR: Inconsistent account balance: ${:,} vs ${:,}".format(
8587
current, total

0 commit comments

Comments
 (0)