Skip to content

Commit

Permalink
Fix deadlock in exception case
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Aug 3, 2024
1 parent e20a4b0 commit 6e04e38
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions secretlounge_ng/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ def __init__(self, obj, func, lock=None):
def __enter__(self):
return self.obj
def __exit__(self, exc_type, *_):
if exc_type is None:
self.func(self.obj)
if self.lock is not None:
self.lock.release()
try:
if exc_type is None:
self.func(self.obj)
finally:
if self.lock is not None:
self.lock.release()

class Database():
def __init__(self):
Expand Down

0 comments on commit 6e04e38

Please sign in to comment.