Skip to content

Commit

Permalink
Include lock name when task fails to execute due to TaskLocked.
Browse files Browse the repository at this point in the history
Fixes #757
  • Loading branch information
coleifer committed Aug 1, 2023
1 parent 9cbf17e commit fdbd988
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions huey/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _execute(self, task, timestamp):
self._tasks_in_flight.remove(task)
duration = time_clock() - start
except TaskLockedException as exc:
logger.warning('Task %s not run, unable to acquire lock.', task.id)
logger.warning('Task %s not run, %s.', task.id, exc)
exception = exc
self._emit(S.SIGNAL_LOCKED, task)
except RetryTask as exc:
Expand Down Expand Up @@ -907,7 +907,7 @@ def inner(*args, **kwargs):

def __enter__(self):
if not self._huey.put_if_empty(self._key, '1'):
raise TaskLockedException('unable to set lock: %s' % self._name)
raise TaskLockedException('unable to acquire lock %s' % self._name)

def __exit__(self, exc_type, exc_val, exc_tb):
self._huey.delete(self._key)
Expand Down
2 changes: 1 addition & 1 deletion huey/contrib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def decorator(fn):
def inner(*args, **kwargs):
tid = sem.acquire()
if tid is None:
raise TaskLockedException('unable to acquire lock: %s' %
raise TaskLockedException('unable to acquire lock %s' %
lock_name)
try:
return fn(*args, **kwargs)
Expand Down

0 comments on commit fdbd988

Please sign in to comment.