
    \dU                     R   d Z ddlZddlZddlZddlZddlZddlmZmZ ddl	m
Z
mZmZmZ ddlmZ  G d d          Z ej        e            G d d	ej                  Z G d
 dej                  Z G d dej                  Z G d d          Z G d dej                  ZdS )z(
Tests for L{twisted.python.threadpool}
    N)TeamcreateMemoryWorker)contextfailure
threadable
threadpool)unittestc                   $    e Zd ZdZd Zd ZdgZdS )Synchronizationr   c                 `    || _         || _        t          j                    | _        g | _        d S N)Nwaiting	threadingLocklockruns)selfr   r   s      <lib/python3.11/site-packages/twisted/test/test_threadpool.py__init__zSynchronization.__init__   s*    N$$				    c                    | j                             d          rEt          | j                  dz  st	          j        d           | j                                          n| xj        dz  c_        | j                                          | j                            d            t          | j                  | j	        k    r| j
                                         | j                                          d S )NF   g-C6*?   )r   acquirelenr   timesleepreleasefailuresappendr   r   r   s    r   runzSynchronization.run   s     9U## 	ty>>A% # 
6"""IMMQMM
 			ty>>TV##L  """	r   r#   N)__name__
__module____qualname__r    r   r#   synchronized r   r   r   r      s:        H    0 7LLLr   r   c                   ~    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )ThreadPoolTestsz
    Test threadpools.
    c                     dS )zD
        Return number of seconds to wait before giving up.
        r   r(   r"   s    r   
getTimeoutzThreadPoolTests.getTimeout@   	     qr   c                     t          d          }|D ].}|                    d          r d S t          j        d           /|                     d           d S )Ni@B Fgh㈵>z%A long time passed without succeeding)ranger   r   r   fail)r   r   itemsis       r   _waitForLockzThreadPoolTests._waitForLockF   sc    g 	? 	?A||E"" JtII=>>>>>r   c                     t          j        dd          }|                     |j        d           |                     |j        d           dS )zy
        L{ThreadPool.min} and L{ThreadPool.max} are set to the values passed to
        L{ThreadPool.__init__}.
              N)r   
ThreadPoolassertEqualminmaxr   pools     r   test_attributeszThreadPoolTests.test_attributesO   sL    
 $R,,2&&&2&&&&&r   c                    t          j        dd          }|                                 |                     |j                   |                     t          |j                  d           t          j        dd          }|                     t          |j                  d           |                                 |                     |j                   |                     t          |j                  d           dS )zV
        L{ThreadPool.start} creates the minimum number of threads specified.
        r   r      
   N)r   r7   start
addCleanupstopr8   r   threadsr;   s     r   
test_startzThreadPoolTests.test_startX   s     $Q**

	"""T\**A...$Q++T\**A...

	"""T\**A.....r   c                     t          j        dd          }|                                 |                                 |                    d           |                     t          |j                  d           dS )z
        L{ThreadPool.adjustPoolsize} only modifies the pool size and does not
        start new workers while the pool is not running.
        r   r      N)r   r7   rA   rC   adjustPoolsizer8   r   rD   r;   s     r   test_adjustingWhenPoolStoppedz-ThreadPoolTests.test_adjustingWhenPoolStoppedg   sj    
 $Q**

		AT\**A.....r   c                    t          j        dd          }|                                 |                     |j                   |                     |j        g            d } G d d          } |            }t          j        |          }t          j        |          }|	                    ||           t          j                    }|	                    |j                   |                    |                                            ~~t          j                     |                      |                       |                      |                       dS )z
        Test that creating threads in the threadpool with application-level
        objects as arguments doesn't results in those objects never being
        freed, with the thread maintaining a reference to them as long as it
        exists.
        r   r   c                     d S r   r(   )args    r   workerz<ThreadPoolTests.test_threadCreationArguments.<locals>.worker   s    Dr   c                       e Zd ZdS ):ThreadPoolTests.test_threadCreationArguments.<locals>.DumbNr$   r%   r&   r(   r   r   DumbrO              Dr   rQ   N)r   r7   rA   rB   rC   r8   rD   weakrefrefcallInThreadr   Eventsetwaitr,   gccollectassertIsNone)r   tprM   rQ   unique	workerRef	uniqueRefevents           r   test_threadCreationArgumentsz,ThreadPoolTests.test_threadCreationArgumentsr   sS    "1a((



    	R(((	 	 		 	 	 	 	 	 	 	 K''	K''	 	''' !!
	"""

4??$$%%%

))++&&&))++&&&&&r   c                 H   	
 t          j        dd          }|                                                      |j                                        |j        g            i 	t          j                    t          j                    g 
	
 fd}fd} G d d                       }t          j
        |          }t          j
        |          t          j
        |          |                    ||||           ~~                                                                                                 t          j                                                                                                               ~t          j                                           |                                             
d                                                     t%          	                                          ddg           dS )	ze
        As C{test_threadCreationArguments} above, but for
        callInThreadWithCallback.
        r   r   c                 &   t          j                                                                                                 d<                d<                                                        t          j        |                     d S )Nr^   r_   )rY   rZ   rX   r,   rW   r!   rS   rT   )	successresultonResultDoneonResultWaitrefdict	resultRefr   r_   r^   s	     r   onResultzVThreadPoolTests.test_threadCreationArgumentsCallInThreadWithCallback.<locals>.onResult   s     JLLLdoo//000#,9;;GK #,9;;GK W[0011111r   c                                  S r   r(   )rL   testrQ   s     r   rM   zTThreadPoolTests.test_threadCreationArgumentsCallInThreadWithCallback.<locals>.worker   s    466Mr   c                       e Zd ZdS )RThreadPoolTests.test_threadCreationArgumentsCallInThreadWithCallback.<locals>.DumbNrP   r(   r   r   rQ   rn      rR   r   rQ   )rl   N)r   r7   rA   rB   rC   r8   rD   r   rV   rS   rT   callInThreadWithCallbackrW   rX   r,   rY   rZ   r[   listvalues)r   r\   rj   rM   r]   onResultRefrQ   rf   rg   rh   ri   r_   r^   s   `     @@@@@@@r   4test_threadCreationArgumentsCallInThreadWithCallbackzDThreadPoolTests.test_threadCreationArgumentsCallInThreadWithCallback   sC    "1a((



    	R(((  (( ((		2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2	 	 	 	 		 	 	 	 	 	 	 	 k(++K''	K''	 	##Hff6#JJJ 	$//++,,,

))++&&&))++&&& 

++--(((,)A,..))) 	gnn..//$>>>>>r   c                 T   t          j        dd          }|                     |j        d           |                     |j        d           t          j        t          j        |                    }|                     |j        d           |                     |j        d           dS )z
        Threadpools can be pickled and unpickled, which should preserve the
        number of threads and other parameters.
              N)r   r7   r8   r9   r:   pickleloadsdumps)r   r<   copys      r   test_persistencez ThreadPoolTests.test_persistence   s    
 $Q++1%%%2&&& |FL..//1%%%2&&&&&r   c                    d}t          j                    }|                                 |                     |j                   t          j                    }|                                 t          ||          }t          |          D ]} |||           | 
                    |           |                     |j        d|j         d           dS )z
        Test synchronization of calls made with C{method}, which should be
        one of the mechanisms of the threadpool to execute work in threads.
        r@   zrun() re-entered z timesN)r   r7   rA   rB   rC   r   r   r   r   r/   r3   assertFalser    )r   methodr   r\   r   actorr2   s          r   _threadpoolTestzThreadPoolTests._threadpoolTest   s     "$$



   .""7++q 	 	AF2u'""")SU^)S)S)STTTTTr   c                 .    |                      d           S )z?
        Call C{_threadpoolTest} with C{callInThread}.
        c                 6    |                      |j                  S r   )rU   r#   )r\   r   s     r   <lambda>z3ThreadPoolTests.test_callInThread.<locals>.<lambda>  s    booei6P6P r   )r   r"   s    r   test_callInThreadz!ThreadPoolTests.test_callInThread  s     ##$P$PQQQr   c                 L    G d dt                     fd}t          j        dd          }|                    |           |                                 |                                 |                               }|                     t          |          d           dS )zi
        L{ThreadPool.callInThread} logs exceptions raised by the callable it
        is passed.
        c                       e Zd ZdS )<ThreadPoolTests.test_callInThreadException.<locals>.NewErrorNrP   r(   r   r   NewErrorr     rR   r   r   c                                    r   r(   r   s   r   
raiseErrorz>ThreadPoolTests.test_callInThreadException.<locals>.raiseError      (**r   r   r   N)		Exceptionr   r7   rU   rA   rC   flushLoggedErrorsr8   r   )r   r   r\   errorsr   s       @r   test_callInThreadExceptionz*ThreadPoolTests.test_callInThreadException  s    	 	 	 	 	y 	 	 		 	 	 	 	 "1a((

###




			''11Va(((((r   c                    t          j                                                     g fd}t          j        dd          }|                    |d            |                                 	 |                                |                                 n# |                                 w xY w| 	                    d                    | 
                    d         d           dS )z
        L{ThreadPool.callInThreadWithCallback} calls C{onResult} with a
        two-tuple of C{(True, result)} where C{result} is the value returned
        by the callable supplied.
        c                                                                           |                                |           d S r   r   r!   rd   re   resultswaiters     r   rj   z?ThreadPoolTests.test_callInThreadWithCallback.<locals>.onResult5  =    NNNN7###NN6"""""r   r   r   c                      dS )Nrl   r(   r(   r   r   r   z?ThreadPoolTests.test_callInThreadWithCallback.<locals>.<lambda>;  s    f r   rl   N)r   r   r   r   r7   ro   rA   r3   rC   
assertTruer8   )r   rj   r\   r   r   s      @@r   test_callInThreadWithCallbackz-ThreadPoolTests.test_callInThreadWithCallback*  s     !!	# 	# 	# 	# 	# 	#
 "1a((
##Hnn===



	f%%%GGIIIIBGGIIII
###V,,,,,s   3B B3c                 ~    G d dt                     fd}t          j                                                     g fd}t	          j        dd          }|                    ||           |                                 	 |                                |	                                 n# |	                                 w xY w| 
                    d                    |                     d         t          j                   |                     t          d         j                             dS )z
        L{ThreadPool.callInThreadWithCallback} calls C{onResult} with a
        two-tuple of C{(False, failure)} where C{failure} represents the
        exception raised by the callable supplied.
        c                       e Zd ZdS )RThreadPoolTests.test_callInThreadWithCallbackExceptionInCallback.<locals>.NewErrorNrP   r(   r   r   r   r   M  rR   r   r   c                                    r   r(   r   s   r   r   zTThreadPoolTests.test_callInThreadWithCallbackExceptionInCallback.<locals>.raiseErrorP  r   r   c                                                                           |                                |           d S r   r   r   s     r   rj   zRThreadPoolTests.test_callInThreadWithCallbackExceptionInCallback.<locals>.onResultX  r   r   r   r   N)r   r   r   r   r   r7   ro   rA   r3   rC   r}   assertIsInstancer   Failurer   
issubclasstype)r   r   rj   r\   r   r   r   s       @@@r   0test_callInThreadWithCallbackExceptionInCallbackz@ThreadPoolTests.test_callInThreadWithCallbackExceptionInCallbackF  sW   	 	 	 	 	y 	 	 		 	 	 	 	 !!	# 	# 	# 	# 	# 	#
 "1a((
##Hj999



	f%%%GGIIIIBGGIIII$$$gaj'/:::
71:?H==>>>>>s   B5 5Cc                     G d dt                     t          j                    }|                                 g fd}t	          j        dd          }|                    |d            |                    |j                   |	                                 	 | 
                    |           |                                 n# |                                 w xY w|                               }|                     t          |          d           |                     d                    |                     d                    dS )zj
        L{ThreadPool.callInThreadWithCallback} logs the exception raised by
        C{onResult}.
        c                       e Zd ZdS )RThreadPoolTests.test_callInThreadWithCallbackExceptionInOnResult.<locals>.NewErrorNrP   r(   r   r   r   r   p  rR   r   r   c                 l                         |                                 |                        r   )r!   )rd   re   r   r   s     r   rj   zRThreadPoolTests.test_callInThreadWithCallbackExceptionInOnResult.<locals>.onResultx  s3    NN7###NN6"""(**r   r   r   c                      d S r   r(   r(   r   r   r   zRThreadPoolTests.test_callInThreadWithCallbackExceptionInOnResult.<locals>.<lambda>~  s    d r   N)r   r   r   r   r   r7   ro   rU   r   rA   r3   rC   r   r8   r   r   r[   )r   r   rj   r\   r   r   r   s        @@r   0test_callInThreadWithCallbackExceptionInOnResultz@ThreadPoolTests.test_callInThreadWithCallbackExceptionInOnResultj  sZ   	 	 	 	 	y 	 	 	 !!	 	 	 	 	 	
 "1a((
##Hll;;;
'''



	f%%%GGIIIIBGGIIII''11Va(((
###'!*%%%%%s    C
 
C c                    g t          j                    fd}fd}t          j        dd          }|                    ||           |                                 |                     |j                                       | 	                                           | 
                    t                    d           | 
                    d         d                    dS )z
        L{ThreadPool.callInThreadWithCallback} calls the function it is
        given and the C{onResult} callback in the same thread.
        c                                          t          j                    j                                                    d S r   )r!   r   current_threadidentrW   )rd   re   r`   	threadIdss     r   rj   z5ThreadPoolTests.test_callbackThread.<locals>.onResult  s4    Y577=>>>IIKKKKKr   c                  ^                          t          j                    j                   d S r   )r!   r   r   r   )r   s   r   funcz1ThreadPoolTests.test_callbackThread.<locals>.func  s)    Y577=>>>>>r   r   r   rG   N)r   rV   r   r7   ro   rA   rB   rC   rX   r,   r8   r   )r   rj   r   r\   r`   r   s       @@r   test_callbackThreadz#ThreadPoolTests.test_callbackThread  s    
 	!!	 	 	 	 	 		? 	? 	? 	? 	? "1a((
##Hd333



   

4??$$%%%Y+++1y|44444r   c                 \   t           j                                        j        d         }d|d<   g t	          j                    fd}fd}t          j        dd          }|                    ||           |	                                 | 
                    |j                                       |                                            |                     t                    d           |                     |d                    |                     |d                    d	S )
z
        The context L{ThreadPool.callInThreadWithCallback} is invoked in is
        shared by the context the callable and C{onResult} callback are
        invoked in.
        zthis must be presenttestingc                     t           j                                        j        d         }                    |                                            d S Nr   )r   theContextTrackercurrentContextcontextsr!   rW   )rd   re   ctxr   r`   s      r   rj   z6ThreadPoolTests.test_callbackContext.<locals>.onResult  sB    +::<<EbICOOC   IIKKKKKr   c                      t           j                                        j        d         }                     |            d S r   )r   r   r   r   r!   )r   r   s    r   r   z2ThreadPoolTests.test_callbackContext.<locals>.func  s7    +::<<EbICOOC     r   r   r   rG   N)r   r   r   r   r   rV   r   r7   ro   rA   rB   rC   rX   r,   r8   r   )r   myctxrj   r   r\   r   r`   s        @@r   test_callbackContextz$ThreadPoolTests.test_callbackContext  s2    )88::CBG1i!!	 	 	 	 	 	
	! 	! 	! 	! 	! "1a((
##Hd333



   

4??$$%%%X***,,,,,,,,r   c                 `   t          j                    }|                                 t          j        dd          }|                    |j                   |                                 	 |                     |           |	                                 dS # |	                                 w xY w)z
        Work added to the threadpool before its start should be executed once
        the threadpool is started: this is ensured by trying to release a lock
        previously acquired.
        r   r   N)
r   r   r   r   r7   rU   r   rA   r3   rC   )r   r   r\   s      r   test_existingWorkz!ThreadPoolTests.test_existingWork  s     !!"1a((
'''



	f%%%GGIIIIIBGGIIIIs   ,B B-c                 (   t          j        dd          }|                                 |                     |j                   |                     |j        d           |                     t          |j                  d           |                     t          |j	                  d           t          j                    t          j                    fd}|                    |                               d           |                     |j        d           |                     t          |j                  d           |                     t          |j	                  d                                            t          |j                  s(t          j        d           t          |j                  (|                     t          |j                  d           |                     t          |j	                  d           dS )z{
        As the worker receives and completes work, it transitions between
        the working and waiting states.
        r   r   c                  Z                                                           d           d S )Nr@   )rW   rX   )threadFinishthreadWorkings   r   _threadz;ThreadPoolTests.test_workerStateTransition.<locals>._thread  s/    b!!!!!r   r@   gMb@?N)r   r7   rA   rB   rC   r8   workersr   waitersworkingr   rV   rU   rX   rW   r   r   )r   r<   r   r   r   s      @@r   test_workerStateTransitionz*ThreadPoolTests.test_workerStateTransition  s   
 $Q**

	""" 	q)))T\**A...T\**A... ")) ((	" 	" 	" 	" 	" 	" 	'"""2q)))T\**A...T\**A... 	dl## 	Jv dl## 	 	T\**A...T\**A.....r   N)r$   r%   r&   __doc__r,   r3   r=   rE   rI   ra   rs   r{   r   r   r   r   r   r   r   r   r   r   r(   r   r   r*   r*   ;   s:          ? ? ?' ' '/ / /	/ 	/ 	/(' (' ('TH? H? H?T' ' ' U U U4R R R) ) )(- - -8"? "? "?H!& !& !&F5 5 52- - -B  $#/ #/ #/ #/ #/r   r*   c                        e Zd Zd Zd Zd ZdS )RaceConditionTestsc                      t          j        dd           _         t          j                     _         j                                           fd}                     |           d S )Nr   r@   c                  >     j                                           ` d S r   )r   rC   r"   s   r   donez&RaceConditionTests.setUp.<locals>.done  s     O  """r   )r   r7   r   rV   r`   rA   rB   )r   r   s   ` r   setUpzRaceConditionTests.setUp   sm    $/266_&&
	  	  	  	  	  	r   c                     dS )z=
        A reasonable number of seconds to time out.
        r   r(   r"   s    r   r,   zRaceConditionTests.getTimeout  r-   r   c                 V   |                                  }| j                            | j        j                   | j                            |           | j                                         t          d          D ]&}| j                            | j        j                   '| j                            | j        j                   | j                            |           | j                                        s0| j                                         | 	                    d           dS dS )a  
        If multiple threads are waiting on an event (via blocking on something
        in a callable passed to L{threadpool.ThreadPool.callInThread}), and
        there is spare capacity in the threadpool, sending another callable
        which will cause those to un-block to
        L{threadpool.ThreadPool.callInThread} will reliably run that callable
        and un-block the blocked threads promptly.

        @note: This is not really a unit test, it is a stress-test.  You may
            need to run it with C{trial -u} to fail reliably if there is a
            problem.  It is very hard to regression-test for this particular
            bug - one where the thread pool may consider itself as having
            "enough capacity" when it really needs to spin up a new thread if
            it possibly can - in a deterministic way, since the bug can only be
            provoked by subtle race conditions.
        r?   z9'set' did not run in thread; timed out waiting on 'wait'.N)
r,   r   rU   r`   rW   rX   clearr/   isSetr0   )r   timeoutr2   s      r   test_synchronizationz'RaceConditionTests.test_synchronization  s   " //##$$TZ^444
   
q 	: 	:AO((9999$$TZ^444
   z!! 	SJNNIIQRRRRR	S 	Sr   N)r$   r%   r&   r   r,   r   r(   r   r   r   r     sF        	 	 	  S S S S Sr   r   c                       e Zd ZdZd Zd ZdS )
MemoryPoolz
    A deterministic threadpool that uses in-memory data structures to queue
    work rather than threads to execute work.
    c                 d    || _         || _        || _        t          j        j        | g|R i | dS )a  
        Initialize this L{MemoryPool} with a test case.

        @param coordinator: a worker used to coordinate work in the L{Team}
            underlying this threadpool.
        @type coordinator: L{twisted._threads.IExclusiveWorker}

        @param failTest: A 1-argument callable taking an exception and raising
            a test-failure exception.
        @type failTest: 1-argument callable taking (L{Failure}) and raising
            L{unittest.FailTest}.

        @param newWorker: a 0-argument callable that produces a new
            L{twisted._threads.IWorker} provider on each invocation.
        @type newWorker: 0-argument callable returning
            L{twisted._threads.IWorker}.
        N)_coordinator	_failTest
_newWorkerr   r7   r   )r   coordinatorfailTest	newWorkerargskwargss         r   r   zMemoryPool.__init__5  sD    $ (!#&t=d===f=====r   c                 R      fd}t           j        | j                  S )a  
        Override testing hook to create a deterministic threadpool.

        @param currentLimit: A 1-argument callable which returns the current
            threadpool size limit.

        @param threadFactory: ignored in this invocation; a 0-argument callable
            that would produce a thread.

        @return: a L{Team} backed by the coordinator and worker passed to
            L{MemoryPool.__init__}.
        c                                                       } | j        | j        z                k    rd S                                 S r   )
statisticsbusyWorkerCountidleWorkerCountr   )statscurrentLimitr   teams    r   respectLimitz&MemoryPool._pool.<locals>.respectLimitZ  sE     OO%%E%(==,,..PPt??$$$r   )r   createWorkerlogException)r   r   r   )r   r   threadFactoryr   r   s   ``  @r   _poolzMemoryPool._poolL  sS    	% 	% 	% 	% 	% 	% 	% )%
 
 

 r   N)r$   r%   r&   r   r   r   r(   r   r   r   r   /  s<         
> > >.    r   r   c                       e Zd ZdZd Zd ZdS )
PoolHelpera  
    A L{PoolHelper} constructs a L{threadpool.ThreadPool} that doesn't actually
    use threads, by using the internal interfaces in L{twisted._threads}.

    @ivar performCoordination: a 0-argument callable that will perform one unit
        of "coordination" - work involved in delegating work to other threads -
        and return L{True} if it did any work, L{False} otherwise.

    @ivar workers: the workers which represent the threads within the pool -
        the workers other than the coordinator.
    @type workers: L{list} of 2-tuple of (L{IWorker}, C{workPerformer}) where
        C{workPerformer} is a 0-argument callable like C{performCoordination}.

    @ivar threadpool: a modified L{threadpool.ThreadPool} to test.
    @type threadpool: L{MemoryPool}
    c                      t                      \  } _        g  _         fd}t          ||j        |g|R i | _        dS )z
        Create a L{PoolHelper}.

        @param testCase: a test case attached to this helper.

        @type args: The arguments passed to a L{threadpool.ThreadPool}.

        @type kwargs: The arguments passed to a L{threadpool.ThreadPool}
        c                  v     j                             t                                  j         d         d         S )Nr   r   )r   r!   r   r"   s   r   r   z&PoolHelper.__init__.<locals>.newWorker  s2    L 2 4 4555<#A&&r   N)r   performCoordinationr   r   r0   r   )r   testCaser   r   r   r   s   `     r   r   zPoolHelper.__init__}  ss     1C0D0D-T-	' 	' 	' 	' 	' %	
48
 
 
<B
 
r   c                 \    |                                  r	 |                                  dS dS )z
        Perform all currently scheduled "coordination", which is the work
        involved in delegating work to other threads.
        N)r   r"   s    r   performAllCoordinationz!PoolHelper.performAllCoordination  sE    
 &&(( 	 &&(( 	 	 	 	 	r   N)r$   r%   r&   r   r   r   r(   r   r   r   r   k  s<         "
 
 
*    r   r   c                       e Zd ZdZd Zd ZdS )MemoryBackedTestszn
    Tests using L{PoolHelper} to deterministically test properties of the
    threadpool implementation.
    c                    t          | dd          }d}t          |          D ]}|j                            d            |                                 |                     |j        g            |j                                         |                                 |                     t          |j                  |           dS )z
        If a threadpool is told to do work before starting, then upon starting
        up, it will start enough workers to handle all of the enqueued work
        that it's been given.
        r   r@   r   c                      d S r   r(   r(   r   r   r   z;MemoryBackedTests.test_workBeforeStarting.<locals>.<lambda>      4 r   N)	r   r/   r   rU   r   r8   r   rA   r   r   helpernxs       r   test_workBeforeStartingz)MemoryBackedTests.test_workBeforeStarting  s     D!R((q 	9 	9A**<<8888%%''',,,!!!%%'''V^,,a00000r   c                    t          | dd          }d}t          |          D ]}|j                            d            |                                 |                     |j        g            |j                                         |                                 |                     t          |j                  |j        j	                   dS )z
        If the amount of work before starting exceeds the maximum number of
        threads allowed to the threadpool, only the maximum count will be
        started.
        r   r@   2   c                      d S r   r(   r(   r   r   r   zBMemoryBackedTests.test_tooMuchWorkBeforeStarting.<locals>.<lambda>  r   r   N)
r   r/   r   rU   r   r8   r   rA   r   r:   r   s       r   test_tooMuchWorkBeforeStartingz0MemoryBackedTests.test_tooMuchWorkBeforeStarting  s     D!R((q 	9 	9A**<<8888%%''',,,!!!%%'''V^,,f.?.CDDDDDr   N)r$   r%   r&   r   r   r  r(   r   r   r   r     sA         
1 1 1 E E E E Er   r   )r   rY   rw   r   r   rS   twisted._threadsr   r   twisted.pythonr   r   r   r   twisted.trialr	   r   synchronizeSynchronousTestCaser*   r   r7   r   r   r   r(   r   r   <module>r
     s   
 
			        5 5 5 5 5 5 5 5 C C C C C C C C C C C C " " " " " "! ! ! ! ! ! ! !H 
  ' ' 'A/ A/ A/ A/ A/h2 A/ A/ A/H-S -S -S -S -S5 -S -S -S`9 9 9 9 9& 9 9 9x- - - - - - - -`$E $E $E $E $E4 $E $E $E $E $Er   