From a8366fe00f2cfece6efa28de70855863f5057387 Mon Sep 17 00:00:00 2001 From: Mike Cifelli <1836280-mike-cifelli@users.noreply.gitlab.com> Date: Mon, 26 Dec 2022 17:22:51 -0500 Subject: [PATCH] Fix locking --- garage.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/garage.py b/garage.py index ad1b957..fae4b08 100644 --- a/garage.py +++ b/garage.py @@ -36,39 +36,27 @@ def main(): def eastDoorOpened(): - try: - threadLock.aquire() + with threadLock: state["east-door"] = "opened" persistState() - finally: - threadLock.release() def eastDoorClosed(): - try: - threadLock.aquire() + with threadLock: state["east-door"] = "closed" persistState() - finally: - threadLock.release() def westDoorOpened(): - try: - threadLock.aquire() + with threadLock: state["west-door"] = "opened" persistState() - finally: - threadLock.release() def westDoorClosed(): - try: - threadLock.aquire() + with threadLock: state["west-door"] = "closed" persistState() - finally: - threadLock.release() def persistState():