release semaphore on exceptions

This commit is contained in:
Jannes Höke 2016-04-24 13:43:42 +02:00
parent 1450478d27
commit 5a7a62c3d8

View file

@ -61,10 +61,13 @@ def run_async(func):
""" """
A wrapper to run a thread in a thread pool A wrapper to run a thread in a thread pool
""" """
result = func(*pargs, **kwargs) try:
semaphore.release() result = func(*pargs, **kwargs)
with async_lock: finally:
async_threads.remove(current_thread()) semaphore.release()
with async_lock:
async_threads.remove(current_thread())
return result return result
@wraps(func) @wraps(func)