
    7Th}                        S SK r S SKrS SKrS SKrS SKJrJrJrJrJ	r	  S SK
JrJr  S SKJr  SSKJrJr  S r\R&                  R                   S 5       r\R&                  R                   S	 5       r\\R&                  R                   S
 5       5       r\R&                  R                   S 5       r\R&                  R                   S 5       rg)    N)AsyncMemorizedFuncAsyncNotMemorizedFuncMemorizedResultMemoryNotMemorizedResult)np
with_numpy)raises   )corrupt_single_cache_itemmonkeypatch_cached_func_warnc                    #    [        USS9nUR                  U 5      n [        S5       H@  n[        S5       H.  nU " U5      I Sh  vN nXd:X  d   e[        U5      US-   :X  a  M.   e   MB     g N(7f)z<Similar to check_identity_lazy_async for coroutine functionsr   locationverbose      Nr   )r   cacherangelen)funcaccumulatorr   memoryi_values          U/var/www/auris/envauris/lib/python3.13/site-packages/joblib/test/test_memory_async.pycheck_identity_lazy_asyncr      sj     Xq1F<<D1XqAq'ME::{#q1u,,,  !s   AA0A.A0%
A0c           	        ^	#    [        5       m	U	4S jn[        UT	U R                  5      I S h  vN   S H  nS H  n[        U R                  SUUS9n[        R
                  " U R                  SS9  UR                  U5      nU" S5      I S h  vN   UR                  S	S
9  [        T	5      nU" S5      I S h  vN nM     [        T	5      WS-   :X  d   eWR                  US5      I S h  vN nUW:X  d   e[        T	5      US-   :X  a  M   e   SUl
        [        U R                  SS9nUR                  U5      " S5      I S h  vN   g  GN N N Nf N7f)Nc                 r   >#    [         R                  " S5      I S h  vN   TR                  S5        U $  N7fN皙?r   asynciosleepappend)nr   s    r   f(test_memory_integration_async.<locals>.f#   0     mmC   1 	!   757)FT)rN
   )r   r   	mmap_modecompressT)ignore_errorsr   F)warn__main__r   r   )listr   strpathr   shutilrmtreer   clearr   eval
__module__)
tmpdirr(   r/   r.   r   gcurrent_accumulatoroutevaledr   s
            @r   test_memory_integration_asyncr?      sG    &K
 $A{FNN
CCC "$I#!	F MM&..=QAA$JJGGG"%k"2!*C# %& ;#6#::::{{1a((}};#6#::::1 "8 ALV^^Q7F
,,q/!
C D$   ) s^   +EE
AEE)E8E91E*E+E9EEEEEEEc                     ^#    [        5       mU4S jn [        S SS9nUR                  U 5      n[        S5       H2  n[	        T5      nU" S5      I S h  vN   [	        T5      US-   :X  a  M2   e   g  N7f)Nc                 r   >#    [         R                  " S5      I S h  vN   TR                  S5        U $  N7fr!   r#   )xr   s    r   ff test_no_memory_async.<locals>.ffP   r*   r+   r   r      r   )r3   r   r   r   r   )rC   r   ggr   r<   r   s        @r   test_no_memory_asyncrG   L   sn     &K
 T1-F	b	B1X!+.e;#6#:::: s   AA3A1A3,A3c                   #    [        U R                  SSS9nUR                  5       S 5       n[        R                  " S5      nU" U5      I Sh  vN nU" U5      I Sh  vN n[        U[        R                  5      (       d   eUR                  S:X  d   e[        U[        R                  5      (       d   eUR                  S:X  d   eAA[        R                  " 5         [        U5        [        X15      nU" U5      I Sh  vN n[        U5      S:X  d   eSn	XS   ;   d   e[        U[        R                  5      (       d   eUR                  S:X  d   eg GN	 N NZ7f)	z8Check that mmap_mode is respected even at the first callr,   r   )r   r.   r   c                    #    U S-  $ 7f)Nr    )as    r   twice6test_memory_numpy_check_mmap_mode_async.<locals>.twiced   s     1us   r   Nr   zException while loading results)r   r4   r   r   ones
isinstancememmapmodegccollectr   r   r   )
r:   monkeypatchr   rL   rK   bcrecorded_warningsdexception_msgs
             r   'test_memory_numpy_check_mmap_mode_asyncrZ   ]   s3    
 V^^sAFF\\^  	
AAhAAhAa####66S==a####66S== 	
	JJLf% 5UHAhA !Q&&&5Ma0000a####66S==3 	$ 	s8   AEEEE B"EEAEEEc           	      r  #    SS jn[        [        XR                  5      [        U5      [	        U R                  SS9R                  U5      [	        S S9R                  U5      4[        [        [        [        45       H  u  p#[        S5       HD  nUR                  S5      I S h  vN n[        XS5      (       d   eUR                  5       S:X  a  MD   e   WR                  5         [        [        5         UR                  5         S S S 5        UR                  5         M     g  N}! , (       d  f       N%= f7f)Nc                 Z   #    [         R                  " S5      I S h  vN   U S-  U-   $  N7f)Nr"   r   )r$   r%   )rB   ys     r   r(   %test_call_and_shelve_async.<locals>.f   s)     mmC   !tax 	!s   +)+r   r   )r   r      )r   )zipr   r4   r   r   r   r   r   r   call_and_shelverO   getr7   r
   KeyError)r:   r(   r   Resultr   results         r   test_call_and_shelve_asyncrf      s     
 q..1!!$FNNA6<<Q?D!''*		
 		
 qA//22Ff----::<1$$$ 
 	HJJL - 3
 s0   B$D7&D$'(D7#D76D&D7&
D4	0D7c                 *  #    S nU R                  US/S9n0 nU" SU5      I S h  vN S:X  d   eU" SU5      I S h  vN S:X  d   eUR                  SU5      I S h  vN u  pEUS:X  d   S5       e[        U[        5      (       d   S5       eg  Ng NR N47f)Nc                    #    [         R                  " S5      I S h  vN   UR                  U S5      S-   X'   X   $  N7f)Nr"   r   r   )r$   r%   rb   )rB   counters     r   rC   *test_memorized_func_call_async.<locals>.ff   s;     mmC   [[A&*
z 	!s   >< >ri   )ignorer   r   zf has not been called properlyz0Metadata are not returned by MemorizedFunc.call.)r   callrO   dict)r   rC   rF   ri   rB   metas         r   test_memorized_func_call_asyncro      s     
 
b)	-BGAw1$$$Aw1$$$GGAw''GA63336dD!!U#UU!  's1   #BBBBBB1BBB)r$   rR   r5   pytestjoblib.memoryr   r   r   r   r   joblib.test.commonr   r	   joblib.testingr
   test_memoryr   r   r   markr?   rG   rZ   rf   ro   rJ       r   <module>rw      s     	    . ! P- ) )X ; ;  #  #L  > V Vrv   