Skip to content

Commit

Permalink
refactor(channels): Invert condition to use early return and remove a…
Browse files Browse the repository at this point in the history
… level of indentation
  • Loading branch information
elisa-a-v committed Nov 13, 2024
1 parent c73ba9d commit 8c785fe
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bc/channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,12 @@ def validate_access_token(self):
)
raise e
finally:
if lock.owned():
try:
lock.release()
except Exception as e:
logger.error(
f"Error releasing lock for channel {self}:\n{e}"
)
if not lock.owned():
return
try:
lock.release()
except Exception as e:
logger.error(f"Error releasing lock for channel {self}:\n{e}")

def _refresh_access_token(self):
api = self.get_api_wrapper()
Expand Down

0 comments on commit 8c785fe

Please sign in to comment.