mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-05 18:27:22 +01:00
Merge pull request #251 from python-telegram-bot/fix_run_async
release semaphore on exceptions
This commit is contained in:
commit
564baea8c3
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
|
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)
|
||||||
|
|
Loading…
Reference in a new issue