
     h                        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ZddlmZ ddl	m
Z
mZ 	 ddlZn# e$ r dZY nw xY w	 ddlZd Zn# e$ r d ZdZY nw xY w	 ddlmZ d Zd	 Zn# e$ r
 d
 ZdxZZY nw xY w e            ZddZd Z eedu d          Z eej                            d           d          Z eedu d          Z eedud          ZdS )z
Small utilities for testing.
    N)mp)SkipTestskipifc                     | S )*A decorator to skip tests requiring numpy. funcs    N/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/joblib/test/common.py
with_numpyr              c                     d }|S )r   c                       t          d          )NzTest requires numpyr   r   r   r   my_funczwith_numpy.<locals>.my_func   s    0111r   r   )r
   r   s     r   r   r      s    	2 	2 	2r   )memory_usagec                     | S )4A decorator to skip tests requiring memory_profiler.r   r	   s    r   with_memory_profilerr   *   r   r   c                     t          j                     t          | ||fd          }t          |          t	          |          z
  S )z)Compute memory usage when executing func.gMbP?)interval)gccollectr   maxmin)r
   argskwargsmem_uses       r   memory_usedr    .   s=    

dF3dCCC7||c'll**r   c                     d }|S )r   c                       t          d          )NzTest requires memory_profiler.r   r   r   r   
dummy_funcz(with_memory_profiler.<locals>.dummy_func7   s    ;<<<r   r   )r
   r#   s     r   r   r   5   s    	= 	= 	=r      c                     dt           j        v sdt          j        v rdS t	          |            d }t          j        ||          xt          | <   }|                                 dS )zTimeout based suiciding thread to kill the test runner process

    If some subprocess dies in an unexpected way we don't want the
    parent process to block indefinitely.
    NO_AUTOKILLz--pdbNc                     t          j                    } t          d| z             t          j        | t          j                   t          j        d           t          d| z             t          j        | t          j                   d S )Nz1Timeout exceeded: terminating stalled process: %dg      ?z-Timeout exceeded: killing stalled process: %d)	osgetpidprintkillsignalSIGTERMtimesleepSIGKILL)pids    r   autokillz setup_autokill.<locals>.autokillR   sr    ikkACGHHH
V^$$$ 	
3=CDDD
V^$$$$$r   )	r(   environsysargvteardown_autokill	threadingTimer_KILLER_THREADSstart)module_nametimeoutr2   ts       r   setup_autokillr>   D   so     
""g&9&9 k"""% % % (1w'I'IIOK 1GGIIIIIr   c                 j    t                               |           }||                                 dS dS )z)Cancel a previously started killer threadN)r9   getcancel)r;   killers     r   r6   r6   `   s4      --F r   zNeeds multiprocessing to run.)reasonz/dev/shmz5This test requires a large /dev/shm shared memory fs.zNeeds lz4 compression to runz$Needs lz4 not being installed to run)r$   )__doc__r7   r,   r.   r(   r4   r   joblib._multiprocessing_helpersr   joblib.testingr   r   lz4ImportErrornumpynpr   memory_profilerr   r   r    dictr9   r>   r6   with_multiprocessingpathexistswith_dev_shmwith_lz4without_lz4r   r   r   <module>rS      sA          				 



 				 . . . . . . + + + + + + + +JJJJ   
CCC         
 
BBB&,,,,,,  + + + +  & & &   "&%L;;;& $&&   8   v$J68 8 8  v
z"""BD D D 6#+&DEEEftOBD D Ds/   / 99A 
AAA# #A21A2