7ec@s ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z dgZ ejdkrddlmZdefdYZndefd YZd efd YZdefd YZdS( iN(tFinalizetinfo(tassert_spawningt BufferWrappertwin32(RtArenacBs/eZejZdZdZdZRS(cCs||_dtjtjjf|_tjd|jd|j|_t j dksjt d|j|jf|_ dS(Ns pym-%d-%dittagnameistagname already in use( tsizetostgetpidRt_countertnexttnametmmaptbufferRt GetLastErrortAssertionErrort_state(tselfR((s,/usr/lib64/python2.7/multiprocessing/heap.pyt__init__=s  "!cCst||jS(N(RR(R((s,/usr/lib64/python2.7/multiprocessing/heap.pyt __getstate__Ds cCsY|\|_|_|_tjd|jd|j|_tjtjksUtdS(NiR( RR RR RRRtERROR_ALREADY_EXISTSR(Rtstate((s,/usr/lib64/python2.7/multiprocessing/heap.pyt __setstate__Hs!(t__name__t __module__t itertoolstcountR RRR(((s,/usr/lib64/python2.7/multiprocessing/heap.pyR9s   cBseZdZRS(cCs+tjd||_||_d|_dS(Ni(R RRtNoneR (RR((s,/usr/lib64/python2.7/multiprocessing/heap.pyRQs (RRR(((s,/usr/lib64/python2.7/multiprocessing/heap.pyROstHeapcBsbeZdZejdZedZdZdZ dZ dZ dZ dZ RS( icCsmtj|_tj|_||_g|_i|_i|_ i|_ t |_ g|_ g|_dS(N(RR t_lastpidt threadingtLockt_lockt_sizet_lengthst _len_to_seqt_start_to_blockt_stop_to_blocktsett_allocated_blockst_arenast_pending_free_blocks(RR((s,/usr/lib64/python2.7/multiprocessing/heap.pyR^s       cCs|d}|||@S(Ni((tnt alignmenttmask((s,/usr/lib64/python2.7/multiprocessing/heap.pyt_roundupks c Cstj|j|}|t|jkr|jt|j|tj}|jd9_t d|t |}|j j ||d|fS|j|}|j |}|j}|s|j |=|j|=n|\}}}|j||f=|j||f=|S(Nis"allocating a new mmap of length %di(tbisectt bisect_leftR#tlenR.tmaxR"R tPAGESIZERRR)tappendR$tpopR%R&( RRtitlengthtarenatseqtblocktstarttstop((s,/usr/lib64/python2.7/multiprocessing/heap.pyt_mallocqs"!      c Cs!|\}}}y|j||f}Wntk r9nX|j|\}}y|j||f}Wntk rynX|j|\}}|||f}||}y|j|j|Wn4tk r|g|j|#s