U e5d¥!ã@sÔddlZddlZddlZddlZddlZddlmZddlmZdddgZe edƒZ ej ej fZ d d d „iZejd kršddlZddlZe ejejd œ¡Gdd„deƒZeƒZejZejZejZejZdd„ZdS)éNé)Úspawn)ÚutilÚensure_runningÚregisterÚ unregisterÚpthread_sigmaskZnoopcCsdS©N©r r r ú8/usr/lib64/python3.8/multiprocessing/resource_tracker.pyÚ!ór Úposix)Z semaphoreZ shared_memoryc@sLeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dS)ÚResourceTrackercCst ¡|_d|_d|_dSr )Ú threadingZLockÚ_lockÚ_fdÚ_pid©Úselfr r r Ú__init__0s zResourceTracker.__init__c CsT|jD|jdkr W5QR£dSt |j¡d|_t |jd¡d|_W5QRXdS)Nr)rrÚosÚcloseÚwaitpidrrr r r Ú_stop5s  zResourceTracker._stopcCs| ¡|jSr )rrrr r r ÚgetfdBszResourceTracker.getfdc Cst|jb|jdk r~| ¡r*W5QR£dSt |j¡z|jdk rPt |jd¡Wntk rfYnXd|_d|_t  d¡g}z|  t j   ¡¡Wntk rªYnXd}t ¡\}}zœzr|  |¡t ¡}|gt ¡}|d||g7}z&trt tjt¡t |||¡}W5tr,t tjt¡XWnt |¡‚YnX||_||_W5t |¡XW5QRXdS)NrzUresource_tracker: process died unexpectedly, relaunching. Some resources might leak.z:from multiprocessing.resource_tracker import main;main(%d)z-c)rrÚ _check_aliverrrrÚChildProcessErrorÚwarningsÚwarnÚappendÚsysÚstderrÚfilenoÚ ExceptionÚpiperZget_executablerZ_args_from_interpreter_flagsÚ _HAVE_SIGMASKÚsignalrÚ SIG_UNBLOCKÚ_IGNORED_SIGNALSÚ SIG_BLOCKZspawnv_passfds)rZ fds_to_passÚcmdÚrÚwZexeÚargsÚpidr r r rFsJ         zResourceTracker.ensure_runningcCs2zt |jd¡Wntk r(YdSXdSdS)Ns PROBE:0:noop FT)rÚwriterÚOSErrorrr r r r†s zResourceTracker._check_alivecCs| d||¡dS)NÚREGISTER©Ú_send©rÚnameÚrtyper r r r‘szResourceTracker.registercCs| d||¡dS)NÚ UNREGISTERr3r5r r r r•szResourceTracker.unregistercCsB| ¡d |||¡ d¡}t|ƒdkr0tdƒ‚t |j|¡}dS)Nz {0}:{1}:{2} Úasciiiz name too long)rÚformatÚencodeÚlenÚ ValueErrorrr0r)rr+r6r7ÚmsgÚnbytesr r r r4™s  zResourceTracker._sendN) Ú__name__Ú __module__Ú __qualname__rrrrrrrr4r r r r r.s @ rc Cst tjtj¡t tjtj¡tr2t tjt¡tj tj fD]&}z |  ¡Wq>t k rbYq>Xq>dd„t  ¡Dƒ}zìt|dƒØ}|D]Ì}z| ¡ d¡ d¡\}}}t  |d¡} | dkrÒtd|›d |›ƒ‚|d krê|| |¡n2|d kr|| |¡n|d krn td |ƒ‚WqŠt k rTztjt ¡ŽWn YnXYqŠXqŠW5QRXW5| ¡D]ž\}}|r®zt dt|ƒ|f¡Wnt k r¬YnX|D]V}zLzt ||ƒWn6t k rþ}zt d||f¡W5d}~XYnXW5Xq²qnXdS)NcSsi|] }|tƒ“qSr )Úset)Ú.0r7r r r Ú ¹szmain..zQresource_tracker: There appear to be %d leaked %s objects to clean up at shutdownzresource_tracker: %r: %sÚrbr9ú:zCannot register z. for automatic cleanup: unknown resource type r2r8ZPROBEzunrecognized command %r)r'ÚSIGINTÚSIG_IGNÚSIGTERMr&rr(r)r!ÚstdinÚstdoutrr$Ú_CLEANUP_FUNCSÚkeysÚitemsrrr<ÚopenÚstripÚdecodeÚsplitÚgetr=ÚaddÚremoveÚ RuntimeErrorÚ excepthookÚexc_info) ÚfdÚfÚcacher7Z rtype_cacher6ÚeÚliner+Z cleanup_funcr r r Úmain«s^   ÿ   þ (r_)rr'r!rrÚrrÚ__all__Úhasattrr&rHrJr)rMr6Z_multiprocessingZ _posixshmemÚupdateZ sem_unlinkZ shm_unlinkÚobjectrZ_resource_trackerrrrrr_r r r r Ús4     ÿ þw