https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/duplicity/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/duplicity/__pycache__/asyncscheduler.cpython-310.pyc
o

�~�_;*�@s�dZddlmZe��ddlmZddlZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZej
��Zej
��ZGd
d�de�ZdS)z_
Asynchronous job scheduler, for concurrent execution with minimalistic
dependency guarantees.
�)�standard_library)�objectN)�log)�require_threading)�interruptably_wait)�async_split)�	with_lockc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�AsyncSchedulera�
    Easy-to-use scheduler of function calls to be executed
    concurrently. A very simple dependency mechanism exists in the
    form of barriers (see insert_barrier()).

    Each instance has a concurrency level associated with it. A
    concurrency of 0 implies that all tasks will be executed
    synchronously when scheduled. A concurrency of 1 indicates that a
    task will be executed asynchronously, but never concurrently with
    other tasks. Both 0 and 1 guarantee strict ordering among all
    tasks (i.e., they will be executed in the order scheduled).

    At concurrency levels above 1, the tasks will end up being
    executed in an order undetermined except insofar as is enforced by
    calls to insert_barrier().

    An AsynchScheduler should be created for any independent process;
    the scheduler will assume that if any background job fails (raises
    an exception), it makes further work moot.
    cCs�t�d|jjtd�|f�|dksJd|jjf��d|_d|_||_d|_d|_	d|_
t��|_
|dkr@td|f�dSdS)zr
        Create an asynchronous scheduler that executes jobs with the
        given level of concurrency.
        �%s: %szinstantiating at concurrency %drz!%s concurrency level must be >= 0FNzconcurrency > 0 (%d))r�Info�	__class__�__name__�_�_AsyncScheduler__failed�_AsyncScheduler__failed_waiter�_AsyncScheduler__concurrency�_AsyncScheduler__worker_count�_AsyncScheduler__waiter_count�_AsyncScheduler__barrier�	threading�	Condition�_AsyncScheduler__cvr)�self�concurrency�r�:/usr/lib/python3/dist-packages/duplicity/asyncscheduler.py�__init__@s ��
�zAsyncScheduler.__init__csDt�d�jjtd�f��jdkr �fdd�}t�j|�dSdS)aL
        Proclaim that any tasks scheduled prior to the call to this
        method MUST be executed prior to any tasks scheduled after the
        call to this method.

        The intended use case is that if task B depends on A, a
        barrier must be inserted in between to guarantee that A
        happens before B.
        r
zinserting barrierrcs
d�_dS�NT)rr�rrr�_insert_barrierfs
z6AsyncScheduler.insert_barrier.<locals>._insert_barrierN)r�Debugrr
rrrr)rrrrr�insert_barrierWs


�zAsyncScheduler.insert_barriercCsn|dusJ�|jdkr!t�d|jjtd�ftjj�|�||�St�d|jjtd�ftjj	�|�
||�S)a�
        Schedule the given task (callable, typically function) for
        execution. Pass the given parameters to the function when
        calling it. Returns a callable which can optionally be used
        to wait for the task to complete, either by returning its
        return value or by propagating any exception raised by said
        task.

        This method may block or return immediately, depending on the
        configuration and state of the scheduler.

        This method may also raise an exception in order to trigger
        failures early, if the task (if run synchronously) or a previous
        task has already failed.

        NOTE: Pay particular attention to the scope in which this is
        called. In particular, since it will execute concurrently in
        the background, assuming fn is a closure, any variables used
        most be properly bound in the closure. This is the reason for
        the convenience feature of being able to give parameters to
        the call, to avoid having to wrap the call itself in a
        function in order to "fixate" variables in, for example, an
        enclosing loop.
        Nrr
z4running task synchronously (asynchronicity disabled)z*scheduling task for asynchronous execution)rrrrr
r�InfoCode�synchronous_upload_begin�"_AsyncScheduler__run_synchronously�asynchronous_upload_begin�#_AsyncScheduler__run_asynchronously)r�fn�paramsrrr�
schedule_taskks

����zAsyncScheduler.schedule_taskcs�fdd�}t�j|�dS)aD
        Wait for the scheduler to become entirely empty (i.e., all
        tasks having run to completion).

        IMPORTANT: This is only useful with a single caller scheduling
        tasks, such that no call to schedule_task() is currently in
        progress or may happen subsequently to the call to wait().
        cst�j�fdd��dS)Ncs�jdko	�jdkS)Nr)rrrrrr�<lambda>�sz4AsyncScheduler.wait.<locals>._wait.<locals>.<lambda>)rrrrrr�_wait�sz"AsyncScheduler.wait.<locals>._waitN)rr)rr+rrr�wait�s	zAsyncScheduler.waitcs8||���fdd�}t�d|jjtd�ftjj�|S)Ncs�S�Nrr��retrr�_waiter�sz3AsyncScheduler.__run_synchronously.<locals>._waiterr
ztask completed successfully)rrrr
rr"�synchronous_upload_done)rr'r(r0rr.r�__run_synchronously�s��z"AsyncScheduler.__run_synchronouslycsJt��fdd��\}}�fdd����fdd�}t�j|���|�|S)Ncs���Sr-rr)r'r(rrr*�sz5AsyncScheduler.__run_asynchronously.<locals>.<lambda>csD�jr t�d�jjtd�ftjj����t	d�jjf��dS)Nr
zJa previously scheduled task has failed; propagating the result immediatelyz9%s: waiter should have raised an exception; this is a bug)
rrrrr
rr"�asynchronous_upload_doner�AssertionErrorrrrr�check_pending_failure�s����zBAsyncScheduler.__run_asynchronously.<locals>.check_pending_failurecs����j�jks�jr@�jdkr!�jsJd��d�_�j��n�jd7_�j���jd8_���j�jks�js�jd7_t�d�j	j
td��jff�dS)Nrzbarrier should be in effectF�r
�active workers = %d)rrrr�	notifyAllrr,rr rr
rr)r5rrr�wait_for_and_register_launch�s

��zIAsyncScheduler.__run_asynchronously.<locals>.wait_for_and_register_launch)rrr�_AsyncScheduler__start_worker)rr'r(�waiter�callerr9r)r5r'r(rr�__run_asynchronously�s

z#AsyncScheduler.__run_asynchronouslycs��fdd�}t�|d�dS)z%
        Start a new worker.
        c	sDz����W�fdd�}t�j|�dS�fdd�}t�j|�w)Ncs>�jd8_t�d�jjtd��jff��j��dS)Nr6r
r7)rrr rr
rrr8rrrr�complete_worker�s
�zJAsyncScheduler.__start_worker.<locals>.trampoline.<locals>.complete_worker)�_AsyncScheduler__execute_callerrr)r>�r<rrr�
trampoline�s�z1AsyncScheduler.__start_worker.<locals>.trampolinerN)�thread�start_new_thread)rr<rArr@r�__start_worker�szAsyncScheduler.__start_workercsP|�\}�|s��fdd�}t�j|�t�d�jjtd�|ftjj�dS)Ncs$�jsd�_��_�j��dSdSr)rrrr8r�rr;rr�_signal_failed�s
�z7AsyncScheduler.__execute_caller.<locals>._signal_failedr
z!task execution done (success: %s))	rrrrrr
rr"r3)rr<�	succeededrFrrEr�__execute_caller�s

��zAsyncScheduler.__execute_callerN)r
�
__module__�__qualname__�__doc__rr!r)r,r$r&r:r?rrrrr	*s2'r	)rK�futurer�install_aliases�builtinsr�	duplicityr�duplicity.dup_threadingrrrr�
dup_threading�
thread_modulerB�threading_modulerr	rrrr�<module>s



https://t.me/RX1948 - 2025