Repository URL to install this package:
|
Version:
3.3.39 ▾
|
python3-tvault-contego
/
usr
/
lib
/
python3
/
dist-packages
/
contego
/
__pycache__
/
async_utils.cpython-35.pyc
|
|---|
º2]× ã @ sX d d l m Z m Z m Z d d l m Z d d l m Z d d Z d d Z d S) é )ÚThreadÚEventÚBoundedSemaphore)Úwraps)ÚRetryExceptionc s" t f d d } | 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 d | d | } | j | S)NÚtargetÚargsÚkwargs)r Ústart)r r Úfunc_hl)Úfunc© ú5/usr/lib/python3/dist-packages/contego/async_utils.pyÚ
async_func s
zrun_async.<locals>.async_func)r )r r r
)r r Ú run_async s r c s f d d } | S)Nc s% t f d d } | S)Nc
s¸ t } f d d } j d r¨ yP | j d | d i t d | d | d | } | j | j | SWq´ t k
r¤ j t d Yq´ Xn t d d S)
Nc
sK | j d } | j d } | j z | | | Wd j Xd 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_funcFr r r r r z Retry....) r ÚacquireÚupdater r
ÚwaitÚ
BaseExceptionr r )r r Úeventr 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)
Ú threadingr r r Ú functoolsr Zcontego.exceptionr r r r
r
r
r Ú<module> s