%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/trial/_dist/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/trial/_dist/__pycache__/disttrial.cpython-312.pyc

�

Ϫ�f�@��j�dZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZmZmZddlmZdd	lmZmZmZdd
lm Z m!Z!ddl"m#Z#ddl$m%Z%dd
l&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7ddl8m9Z9m:Z:ddl;m<Z<ddl=m>Z>m?Z?m@Z@mAZAddlBmCZCmDZDmEZEGd�de e!�ZFdeFfd�ZGeGd�d ��ZHeGd!�d"��ZIeGd#�d$��ZJd%eKd&e/deKfd'�ZLd(eId)ee0d&e<d*e
e<ee0eDge	dfddf
d+�ZMeGd,�d-��ZNy).z�
This module contains the trial distributed runner, the management class
responsible for coordinating all of trial's behavior at the highest level.

@since: 12.3
�N)�partial)�isabs)
�Any�	Awaitable�Callable�Iterable�List�Optional�Sequence�TextIO�Union�cast)�TestCase�	TestSuite)�define�field�frozen)�default_if_none)�Deferred�DeferredList�
gatherResults)�IReactorCore�IReactorProcess)�Logger)�Failure)�FilePath)�FilesystemLock)�
theSystemPath�)�
_iterateTests)�	IReporter�	ITestCase)�UncleanWarningsReporterWrapper)�
TestHolder)�_unusedTestDirectory�openTestLog�)�_WORKER_AMP_STDIN�_WORKER_AMP_STDOUT)�DistReporter)�
countingCalls�
discardResult�iterateWhile�	takeWhile)�LocalWorker�LocalWorkerAMP�WorkerActionc��eZdZdZy)�IDistTrialReactorz7
    The reactor interfaces required by disttrial.
    N)�__name__�
__module__�__qualname__�__doc__���?/usr/lib/python3/dist-packages/twisted/trial/_dist/disttrial.pyr3r33s��r9r3�returnc��ddlmcm}tt	j
|�t
j
|�g�rtt|�Std��)zR
    Get the default reactor, ensuring it is suitable for use with disttrial.
    rNz-Reactor does not provide the right interfaces)
�twisted.internet.reactor�internet�reactor�allr�
providedByrrr3�	TypeError)�defaultReactors r:�_defaultReactorrD9sO��6�5�
��#�#�N�3��&�&�~�6�	
���%�~�6�6�
�C�
D�Dr9c�F�eZdZUdZeed<eeed<ee	ed<e	ed<y)�WorkerPoolConfiga�
    Configuration parameters for a pool of test-running workers.

    @ivar numWorkers: The number of workers in the pool.

    @ivar workingDirectory: A directory in which working directories for each
        of the workers will be created.

    @ivar workerArguments: Extra arguments to pass the worker process in its
        argv.

    @ivar logFile: The basename of the overall test log file.
    �
numWorkers�workingDirectory�workerArguments�logFileN)
r4r5r6r7�int�__annotations__rrr�strr8r9r:rFrFMs'����O��s�m�#��c�]�"�
�Lr9rFc��eZdZUdZeeed<eed<eed<e	e
ed<e	eed<e�Z
deedd	fd
�Zdd�Zy	)
�StartedWorkerPoolaE
    A pool of workers which have already been started.

    @ivar workingDirectory: A directory holding the working directories for
        each of the workers.

    @ivar testDirLock: An object representing the cooperative lock this pool
        holds on its working directory.

    @ivar testLog: The open overall test log file.

    @ivar workers: Objects corresponding to the worker child processes and
        adapting between process-related interfaces and C{IProtocol}.

    @ivar ampWorkers: AMP protocol instances corresponding to the worker child
        processes.
    rH�testDirLock�testLog�workers�
ampWorkers�workerActionr;Nc��^�K�t�fd�|jD���d{���y7��w)zB
        Run an action on all of the workers in the pool.
        c3�@�K�|]}t�|�����y�w�N)r,)�.0�workerrTs  �r:�	<genexpr>z(StartedWorkerPool.run.<locals>.<genexpr>�s �����
�4:�M�,�v�.�/�
�s�N)rrS)�selfrTs `r:�runzStartedWorkerPool.runs6������
�>B�o�o�
�
�	
�	
��	
�s�"-�+�-c	���K�t|jD�cgc]%}tj|j	����'c}d���d{���}t|�D]+\}\}}|r�|jjd|�d�|��-|jdd�=|jdd�=|jj�|jj�ycc}w7���w)zv
        Shut down all of the workers in the pool.

        The pool is unusable after this method is called.
        T)�
consumeErrorsNzjoining disttrial worker #z failed)
rrRr�
fromCoroutine�exit�	enumerate�_logger�failurerSrQ�closerP�unlock)r[rY�results�n�	succeededrcs      r:�joinzStartedWorkerPool.join�s�����%�AE���N�v�X�
#�
#�F�K�K�M�
2�N��
�
��(1��'9�	W�#�A�#�	�7�����$�$�'A�!��G�%L�g�V�	W�
�L�L��O��O�O�A�������������!��
O�
�s#�C$�*C�C$�C"�
C$�(A;C$)r;N)r4r5r6r7rrrLrrr	r/r0rrbr1r\rir8r9r:rOrOcsX���$�s�m�#���
�O�
�+�
���^�$�$��h�G��l�3�&7��D��"r9rOc	�\�eZdZUdZeed<deedee	de
deefd�Z
d�Zd	edefd
�Zy)�
WorkerPoolz�
    Manage a fixed-size collection of child processes which can run tests.

    @ivar _config: Configuration for the precise way in which the pool is run.
    �_config�	protocolsrHrJr;c��t|�D��cgc]*\}}t||jt|��|���,c}}Scc}}w)a�
        Create local worker protocol instances and return them.

        @param protocols: The process/protocol adapters to use for the created
        workers.

        @param workingDirectory: The base path in which we should run the
            workers.

        @param logFile: The test log, for workers to write to.

        @return: A list of C{quantity} C{LocalWorker} instances.
        )rar/�childrM)r[rmrHrJ�x�protocols      r:�_createLocalWorkerszWorkerPool._createLocalWorkers�sF��* )��3�
���8�
��"2�"8�"8��Q��"@�'�J�
�	
��
s�/Ac
��tdjj}ddddddtdtdi}t
jj�}t
jjtj�|d<|D]@}tj|g}|j|�||tj|||���By	)
a
        Spawn processes from a list of process protocols.

        @param spawner: A C{IReactorProcess.spawnProcess} implementation.

        @param protocols: An iterable of C{ProcessProtocol} instances.

        @param arguments: Extra arguments passed to the processes.
        ztwisted.trial._dist.workertrialr�wr'�rr�
PYTHONPATH)�args�childFDs�envN)
r�filePath�pathr(r)�os�environ�copy�pathsepri�sys�
executable�extend)	r[�spawnerrm�	arguments�workertrialPathrxr}rYrws	         r:�_launchWorkerProcessesz!WorkerPool._launchWorkerProcesses�s���(�(I�J�S�S�X�X��
�s�
�s�
�s��s���
���*�*�/�/�#��!#�
�
������ 9�����	W�F��N�N�O�4�D��K�K�	�"��F�C�N�N���g�V�	Wr9r?c��DK�t|jj�\}}t|jj�r t|jj�}n%|j
|jj�}t|�}t|jj�D�cgc]}t���}}|j|||�}|j|j||jj�t|||||�Scc}w�w)z�
        Launch all of the workers for this pool.

        @return: A started pool object that can run jobs using the workers.
        )r%rlrHrrJr�preauthChildr&�rangerGr0rrr��spawnProcessrIrO)	r[r?�testDirrP�testLogPathrQrprSrRs	         r:�startzWorkerPool.start�s����� 4��L�L�)�)� 
��������%�%�&�"�4�<�<�#7�#7�8�K�
"�.�.�t�|�|�/C�/C�D�K��k�*��05�d�l�l�6M�6M�0N�O�1�n�&�O�
�O��*�*����
��
	
�#�#�� � ���L�L�(�(�	
�!������
�	
��P�s�B3D �5D�AD N)r4r5r6r7rFrLrr0rrrr	r/rrr�rrOr�r8r9r:rkrk�sb�����
��N�+�
�#�3�-�
��	
�

�k�	�
�0W�6&
�?�&
�7H�&
r9rk�untilFailure�resultc�*�|xr|j�S)z�
    Determine whether the test suite should be iterated again.

    @param untilFailure: C{True} if the suite is supposed to run until
        failure.

    @param result: The test result of the test suite iteration which just
        completed.
    )�
wasSuccessful)r�r�s  r:�shouldContinuer�s���2�F�0�0�2�2r9�pool�	testCases�driveWorkerc���K�	|jt|||���d{���y7�#t$r0|jj	td�t
��YywxYw�w)Nz
<runTests>)r\r�	Exception�original�addErrorr$r)r�r�r�r�s    r:�runTestsr�sT����F��h�h�w�{�F�I�>�?�?�?���F�	��� � ��L�!9�7�9�E�	F�s1�A'�+�)�+�A'�+�6A$�!A'�#A$�$A'c���eZdZUdZeZe�Zede	fe
d<ee
d<ee
e
d<dZee
d<edee�	��
�Zee
d<edeej,��
�Zee
d<d
Ze
e
d<dZee
d<dZee
d<dZe
e
d<dZe
e
d<eZee gefe
d<defd�Z!d�Z"dede#e$de%ddfd�Z&	d$de'e(e)fdedefd�Z*d e'e(e)fdede	fd!�Z+d e'e(e)fde	fd"�Z,d e'e(e)fde	fd#�Z-y)%�DistTrialRunnera�
    A specialized runner for distributed trial. The runner launches a number of
    local worker processes which will run tests.

    @ivar _maxWorkers: the number of workers to be spawned.

    @ivar _exitFirst: ``True`` to stop the run as soon as a test case fails.
        ``False`` to run through the whole suite and report all of the results
        at the end.

    @ivar stream: stream which the reporter will use.

    @ivar _reporterFactory: the reporter class to be used.
    .�_reporterFactory�_maxWorkers�_workerArgumentsF�
_exitFirstN)�factory)�default�	converter�_reactor�streamr��_tracebackFormat�_realTimeErrors�_uncleanWarningsztest.log�_logfile�_trial_temp�_workingDirectory�_workerPoolFactoryr;c��|j|j|j|j��}|jrt|�}|j
|�S)zL
        Make reporter factory, and wrap it with a L{DistReporter}.
        )�realtime)r�r�r�r�r�r#�_distReporterFactory)r[�reporters  r:�_makeResultzDistTrialRunner._makeResultJsV���(�(��K�K��.�.��9M�9M�)�
��� � �5�h�?�H��(�(��2�2r9c�$�|j�y)z�
        Write test run final outcome to result.

        @param result: A C{TestResult} which will print errors and the summary.
        N)�done)r[r�s  r:�writeResultszDistTrialRunner.writeResultsUs
��	���
r9r�r�rYc��N��K���fd�}|D]}||��d{����y7��w)a�
        Drive a L{LocalWorkerAMP} instance, iterating the tests and calling
        C{run} for every one of them.

        @param worker: The L{LocalWorkerAMP} to drive.

        @param result: The global L{DistReporter} instance.

        @param testCases: The global list of tests to iterate.

        @return: A coroutine that completes after all of the tests have
            completed.
        c���K�	�j|���d{���y7�#t$r'�jj|t	��YywxYw�wrW)r\r�r�r�r)�caser�rYs ��r:�taskz*DistTrialRunner._driveWorker.<locals>.taskqsD�����
:��j�j��v�.�.�.���
:����(�(��w�y�9�
:�s1�A�"� �"�A�"�-A�A�A�ANr8)r[r�r�rYr�r�s ` `  r:�_driveWorkerzDistTrialRunner._driveWorker]s-�����(	:��	�D��t�*���	��s�%�#�%�suiter�c	������K�tt|����jtt	t���j�t�j��j�j��}�jjd|j��d��|j�j��d{����t!t"��}t$dt&dt(f����fd��}	t+||��d{����j-��d{���S7�_7�7�	#�j-��d{���7wxYw�w)a*
        Spawn local worker processes and load tests. After that, run them.

        @param suite: A test or suite to be run.

        @param untilFailure: If C{True}, continue to run the tests until they
            fail.

        @return: A coroutine that completes with the test result.
        zRunning z tests.
Nrgr;c����K��r"�jjd|dz�d���j���jr�fd�}nd�}t	�t|����j��d{����j���S7��w)Nz
Test Pass r'�
c�8���jj�SrW)r�r�)�_r�s �r:�<lambda>z@DistTrialRunner.runAsync.<locals>.runAndReport.<locals>.<lambda>�s���6�?�?�+H�+H�+J�r9c��y�NTr8)r�s r:r�z@DistTrialRunner.runAsync.<locals>.runAndReport.<locals>.<lambda>�s�r9)r��writer�r�r�r.r�r�)rg�casesConditionr�r[�startedPoolr�r�s  @����r:�runAndReportz.DistTrialRunner.runAsync.<locals>.runAndReport�s����������!�!�J�q�1�u�g�R�"8�9��%�%�'�F����"K��!/�����.�)�4���!�!�	�
�
�
���f�%��M�
�s�A/B
�3B�4B
)�listr r�rF�min�lenr�rr�r�r�r�r��countTestCasesr�r�rr�r+rKr*r-ri)r[r�r��poolStarter�	conditionr�r�r�s` `   @@r:�runAsynczDistTrialRunner.runAsynczs!�����"��u�-�.�	��-�-���C�	�N�D�$4�$4�5���/�/�0��%�%��
�
�
�
��	
�����H�U�%9�%9�%;�$<�I�F�G�(�-�-�d�m�m�<�<���N�L�9�	�
�	�#�	�,�	�
�	�0	%�&�i��>�>��"�"�$�$�$�M=��F?��
%��+�"�"�$�$�$�sZ�CE�D'�2E�;D-�
D)�D-�E�!D+�"E�)D-�+E�-E�E�E�E�testc�B�����d�d�dtttfddf�fd�}dttt
f���fd�}dt
dt
f��fd�}�jjdd	|�t	j�j||��j|�j|���jj�t�t�r�j�t�t�s
J��d
���tt�j �S)NFrur;c�
��|�yrWr8)rur�s �r:�capturez%DistTrialRunner._run.<locals>.capture�s����Fr9c�2��d����j��Syr�)�cancel)�reactorStoppingr��testsInProgresss���r:�maybeStopTestsz,DistTrialRunner._run.<locals>.maybeStopTests�s"���"�O��~��&�&�(�&�&�r9r�c�@���s�jj�|SrW)r��stop)r�r�r[s ��r:�maybeStopReactorz.DistTrialRunner._run.<locals>.maybeStopReactor�s���"��
�
�"�"�$��Mr9�before�shutdownz is not DistReporter)r
rr*r
r�objectr��addSystemEventTriggerr_r��addBothr\�
isinstance�raiseExceptionrr!r�)	r[r�r�r�r�r�r�r�r�s	`     @@@r:�_runzDistTrialRunner._run�s����59�� %��	�u�W�l�2�3�	��	�	���&�)9� :�	�	�V�	��	�
	
�
�
�+�+�H�j�.�Q�
�"�"�4�=�=��|�#D�E�
�W�W�
�
�W�%�
&�	�	
�
�
�����f�g�&��!�!�#�
�&�,�/�P�F�8�;O�1P�P�/��I�v���/�/r9c�(�|j|d��S)za
        Run a reactor and a test suite.

        @param test: The test or suite to run.
        F�r��r��r[r�s  r:r\zDistTrialRunner.run�s���y�y��E�y�2�2r9c�(�|j|d��S)z|
        Run the tests with local worker processes until they fail.

        @param test: The test or suite to run.
        Tr�r�r�s  r:�runUntilFailurezDistTrialRunner.runUntilFailure�s���y�y��D�y�1�1r9)F).r4r5r6r7r*r�rrbrr!rLrKr	rMr��boolrrrDr�r3r��stdoutr�rr�r�r�r�r�rkr�rFr�r�rr"r0r�r
rrr�r�r\r�r8r9r:r�r�!s���
�(���h�G��s�I�~�.�.����3�i���J���"'��!�/�:�#�H����4�?�3�:�:�3N�O�F�F�O�%��c�%�!�O�T�!�"��d�"��H�c��*��s�*�CM���"2�!3�Z�!?�@�M�	3�\�	3������I�&���	�

��@#�J%��X�y�(�)�J%��J%�
�	J%�X*0��x��2�3�*0�4�*0�I�*0�X3��h�	�1�2�3�y�3�2�E�(�I�*=�$>�2�9�2r9r�)Or7r|r��	functoolsr�os.pathr�typingrrrrr	r
rrr
r�unittestrr�attrsrrr�attrs.convertersr�twisted.internet.deferrrr�twisted.internet.interfacesrr�twisted.loggerr�twisted.python.failurer�twisted.python.filepathr�twisted.python.lockfiler�twisted.python.modulesr�_asyncrunnerr �itrialr!r"r�r#�runnerr$�utilr%r&�r(r)�distreporterr*�
functionalr+r,r-r.rYr/r0r1r3rDrFrOrkr�r�r�r�r8r9r:�<module>r�sl��
�
�
������)�'�'�,�H�H�E�!�*�,�2�0�(�)�5��4�3�&�M�M�=�=���o��E�*�E�(�����*�5"�5"��5"�p�b
�b
��b
�J
3��
3�y�
3�T�
3�F�
�F��	�"�F�
�F��	�x�	�*�N�;�Y�t�_�L��	F�
�F�$�^2�^2��^2r9

Zerion Mini Shell 1.0