mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-23 06:50:29 +01:00
release semaphore on exceptions
This commit is contained in:
parent
1450478d27
commit
5a7a62c3d8
1 changed files with 7 additions and 4 deletions
|
@ -61,10 +61,13 @@ def run_async(func):
|
|||
"""
|
||||
A wrapper to run a thread in a thread pool
|
||||
"""
|
||||
result = func(*pargs, **kwargs)
|
||||
semaphore.release()
|
||||
with async_lock:
|
||||
async_threads.remove(current_thread())
|
||||
try:
|
||||
result = func(*pargs, **kwargs)
|
||||
finally:
|
||||
semaphore.release()
|
||||
|
||||
with async_lock:
|
||||
async_threads.remove(current_thread())
|
||||
return result
|
||||
|
||||
@wraps(func)
|
||||
|
|
Loading…
Reference in a new issue