Repository URL to install this package:
Version:
4.2.64-4.2 ▾
|
python3-tvault-contego
/
usr
/
lib
/
python3.6
/
site-packages
/
contego
/
__pycache__
/
async_utils.cpython-36.opt-1.pyc
|
---|
3 nS bÕ ã @ s@ d dl mZmZmZ d dlmZ d dlmZ dd Zdd Z dS ) é )ÚThreadÚEventÚBoundedSemaphore)Úwraps)ÚRetryExceptionc s t fdd}|S )aÛ run_async(func) function decorator, intended to make "func" run in a separate thread (asynchronously). Returns the created Thread object E.g.: @run_async def task1(): do_something @run_async def task2(): do_something_too t1 = task1() t2 = task2() ... t1.join() t2.join() c s t | |d}|j |S )N)ÚtargetÚargsÚkwargs)r Ústart)r r Úfunc_hl)Úfunc© ú!/usr/lib/python3.6/async_utils.pyÚ async_func s zrun_async.<locals>.async_func)r )r r r )r r Ú run_async s r c s fdd}|S )Nc s t fdd}|S )Nc s t }fdd}jdrvy2|j| d t|| |d}|j |j |S tk rr j tdY q~X ntdd S )Nc s: |j d}|j d}|j z|| | W d j X d S )NÚthread_start_eventÚactual_func)ÚpopÚsetÚrelease)r r ZtheventZthfunc)Ú throttlingr r Úthread_wrapper_func/ s zYrun_async_by_throttle.<locals>.run_async.<locals>.async_func.<locals>.thread_wrapper_funcF)r r )r r r z Retry....) r ÚacquireÚupdater r ÚwaitÚ BaseExceptionr r )r r Zeventr r )r r r r r + s z<run_async_by_throttle.<locals>.run_async.<locals>.async_func)r )r r )r )r r r * s z(run_async_by_throttle.<locals>.run_asyncr )r r r )r r Úrun_async_by_throttle) s r N) Z threadingr r r Ú functoolsr Zcontego.exceptionr r r r r r r Ú<module> s