%PDF- %PDF-
Direktori : /lib/python3/dist-packages/duplicity/__pycache__/ |
Current File : //lib/python3/dist-packages/duplicity/__pycache__/asyncscheduler.cpython-312.pyc |
� �2e( � �^ � d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ G d� de � Z y) z_ Asynchronous job scheduler, for concurrent execution with minimalistic dependency guarantees. � N)�log)�async_split)�interruptably_wait)� with_lockc �@ � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zy )�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. c �D � t j | j j � dt d� |z � �� |dk\ sJ | j j � d�� �d| _ d| _ || _ d| _ d| _ d| _ t j � | _ y)zr Create an asynchronous scheduler that executes jobs with the given level of concurrency. �: zinstantiating at concurrency %dr z concurrency level must be >= 0FN)r �Info� __class__�__name__�_�_AsyncScheduler__failed�_AsyncScheduler__failed_waiter�_AsyncScheduler__concurrency�_AsyncScheduler__worker_count�_AsyncScheduler__waiter_count�_AsyncScheduler__barrier� threading� Condition�_AsyncScheduler__cv)�self�concurrencys �:/usr/lib/python3/dist-packages/duplicity/asyncscheduler.py�__init__zAsyncScheduler.__init__; s� � � ���D�N�N�+�+�,�B�q�1R�/S�Va�/a�.b�c�d��a��\�D�N�N�$;�$;�#<�<[�!\�\���� �#���(������������ �'�'�)�� � c �� � � t j � j j � dt d� � �� � j dkD r� fd�}t � j |� yy)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 barrierr c � �� d� _ y �NT)r �r s �r �_insert_barrierz6AsyncScheduler.insert_barrier.<locals>._insert_barrier^ s �� �!%��r N)r �Debugr r r r r r )r r! s ` r �insert_barrierzAsyncScheduler.insert_barrierN sX �� � � � �T�^�^�,�,�-�R��2E�0F�/G�H�I� ����!� &� �d�i�i��1� "r c � � |�J �| j dk( rbt j | j j � dt d� � �t j j � | j ||� S t j | j j � dt d� � �t j j � | j ||� 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. r r z4running task synchronously (asynchronicity disabled)z*scheduling task for asynchronous execution)r r r r r r �InfoCode�synchronous_upload_begin�"_AsyncScheduler__run_synchronously�asynchronous_upload_begin�#_AsyncScheduler__run_asynchronously)r �fn�paramss r � schedule_taskzAsyncScheduler.schedule_taskc s� � �2 �~��~� ����"� �H�H��>�>�*�*�+�2�a�0f�.g�-h�i����5�5� � �+�+�B��7�7��H�H��>�>�*�*�+�2�a�0\�.]�-^�_����6�6� � �,�,�R��8�8r c �<