rfc@sddlZddlZddlZddlmZmZddlmZmZdddddd gZ i ej d 6ej d 6ej d 6ej d 6ejd6ejd6ejd6ejd6ejd6ejd6ejd6ejd6ZdZdZdZdZdZdZddZdZdZ dZ!d Z"iZ#ej$Z%d!e&fd"YZ'd#e'fd$YZ(d%e'fd&YZ)d'e)fd(YZ*dS()iN(theaptRLock(tassert_spawningtForkingPicklertRawValuetRawArraytValuetArraytcopyt synchronizedtctutbtBthtHtitItltLtftdcCs.tj|}tj|}t||dS(N(tctypestsizeofRt BufferWrappert rebuild_ctypetNone(ttype_tsizetwrapper((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt _new_value=scGsTtj||}t|}tjtj|dtj||j||S(s> Returns a ctypes object allocated from shared memory i(ttypecode_to_typetgetRRtmemsett addressofRt__init__(ttypecode_or_typetargsRtobj((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyRBs  % cCstj||}t|ttfrf||}t|}tjtj|dtj ||S|t |}t|}|j ||SdS(s= Returns a ctypes array allocated from shared memory iN( RR t isinstancetinttlongRRR!R"RtlenR#(R$tsize_or_initializerRR&tresult((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyRLs  %  cOs|jdd}|r1td|jnt||}|tkrP|S|tdfkrnt}nt|dst d|nt ||S(s6 Return a synchronization wrapper for a Value tlocks$unrecognized keyword argument(s): %stacquires'%r' has no method 'acquire'N( tpopRt ValueErrortkeysRtFalsetTrueRthasattrtAttributeErrorR (R$R%tkwdsR-R&((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR\s  cKs|jdd}|r1td|jnt||}|tkrP|S|tdfkrnt}nt|dst d|nt ||S(s9 Return a synchronization wrapper for a RawArray R-s$unrecognized keyword argument(s): %sR.s'%r' has no method 'acquire'N( R/RR0R1RR2R3RR4R5R (R$R+R6R-R&((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyRls  cCs)tt|}|tj|d<|S(Ni(RttypeRtpointer(R&tnew_obj((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR|scCst|t stdt|tjr;t||St|tjry|jtjkrlt ||St ||St |}yt |}Wnqt k rg|jD]}|d^q}td|D}d|j}t |tf|}t |st Synchronized(R'tSynchronizedBasetAssertionErrorRt _SimpleCDataR=Rt_type_tc_chartSynchronizedStringtSynchronizedArrayR7t class_cachetKeyErrort_fields_tdictt__name__(R&R-tclstsclstfieldtnamesRt classname((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR s        !cCsXt|t|tjr8t|j|j|jffStt||jdffSdS(N( RR'RRRRAt_wrappert_length_R7R(R&((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt reduce_ctypes cCsK|dk r||}ntj|t|j|j}||_|S(N(RRtregisterRQt from_addresst get_addressRO(RRtlengthR&((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyRs    cBsPy e|SWn=ek rKi}e|fd|U||e|<||SXdS(Ni(t prop_cacheRFttemplate(R<R((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR:s  s def get%s(self): self.acquire() try: return self._obj.%s finally: self.release() def set%s(self, value): self.acquire() try: self._obj.%s = value finally: self.release() %s = property(get%s, set%s) R>cBs8eZddZdZdZdZdZRS(cCs=||_|pt|_|jj|_|jj|_dS(N(t_objRt_lockR.trelease(tselfR&R-((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR#s cCs t|t|j|jffS(N(RR RXRY(R[((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt __reduce__s cCs|jS(N(RX(R[((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pytget_objscCs|jS(N(RY(R[((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pytget_lockscCsdt|j|jfS(Ns<%s wrapper for %s>(R7RIRX(R[((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt__repr__sN(RIt __module__RR#R\R]R^R_(((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR>s     R=cBseZedZRS(tvalue(RIR`R:Ra(((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyR=sRDcBs5eZdZdZdZdZdZRS(cCs t|jS(N(R*RX(R[((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt__len__scCs+|jz|j|SWd|jXdS(N(R.RXRZ(R[R((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt __getitem__s cCs-|jz||j|R=RDRC(((s4/usr/lib64/python2.7/multiprocessing/sharedctypes.pyt#s:            "