Merge pull request #251 from python-telegram-bot/fix_run_async

release semaphore on exceptions
This commit is contained in:
Jannes Höke 2016-04-24 15:59:09 +02:00
commit 564baea8c3

View file

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