(YdZddlZddlZddlZddlmZmZddlmZm Z m Z gdZ dddZ d Z d Zd ZGd d ZdZdZGddZeZGddeZGddeZy)z"Subinterpreters High Level Module.N) is_shareableRunFailedError) ChannelErrorChannelNotFoundErrorChannelEmptyError) Interpreter get_currentget_maincreatelist_all SendChannel RecvChannelcreate_channellist_all_channelsrrrrTisolatedcHtj|}t||S)z'Return a new (idle) Python interpreter.r) _interpretersr r)rids @/opt/alt/python312/lib64/python3.12/test/support/interpreters.pyr r s   x 0B rH --cbtjDcgc] }t|c}Scc}w)z!Return all existing interpreters.)rr rrs rr r s)&3&<&<&> ?&>KO&> ?? ?s,c@tj}t|S)z)Return the currently running interpreter.)rr rrs rr r "s  " " $B r?rc@tj}t|S)zReturn the main interpreter.)rr rrs rr r (s    !B r?rcfeZdZdZdddZdZdZdZedZ ed Z d Z d Z dd d Z y)rzA single Python interpreter.Nrc|t|ttjfst d|||_||_yNzid must be an int, got ) isinstanceintr InterpreterID TypeError_id _isolated)selfrrs r__init__zInterpreter.__init__1s8"sM$?$?@A5bV<= =!rctt|j|j}d|j D}t |j ddj|dS)N)rrc30K|]\}}|d|yw)=N).0kvs r z'Interpreter.__repr__..9s8<41aQCq,84::<8t*%%&a &(9':!<> !+66txx@DN~~rc@tj|jS)zrDpropertyrrrKrNrSr*rrrr.sX&'+" = ) 2/+/>rrc^tj}t|t|}}||fS)zReturn (recv, send) for a new cross-interpreter channel. The channel may be used to pass data safely between interpreters. ) _channelsr rr )cidrecvsends rrres/    CS!;s#3$D :rcxtjDcgc]}t|t|fc}Scc}w)z4Return a list of (recv, send) for all open channels.)rYr rr )rZs rrrosA!))+ -+ {3/ 0+ -- -s7c8eZdZdZdZdZdZdZedZ y) _ChannelEndz/The base class for RecvChannel and SendChannel.cnt|ttjfst d|||_yr)rr rY ChannelIDr"r#)r%rs rr&z_ChannelEnd.__init__xs1"sI$7$7895bV<= =rc^t|jdt|jdS)Nz(id=r0)r3r4r r#r=s rr8z_ChannelEnd.__repr__}s(t*%%&d3txx=/;;rc,t|jSr:r;r=s rr>z_ChannelEnd.__hash__r?rct|trt|tstSt|tstS|j|jk(Sr:)rrrAr r#rBs rrDz_ChannelEnd.__eq__s? dK (e[1%%E;/! !yyDHH$$rc|jSr:rFr=s rrz_ChannelEnd.idrGrN) r4rTrUrVr&r8r>rDrWrr*rrr_r_us-9 <%rr_c2eZdZdZedddZefdZy)rz1The receiving end of a cross-interpreter channel.g{Gz?) _sentinel_delayctj|j|}||ur:tj|tj|j|}||ur:|S)zReturn the next object from the channel. This blocks until an object has been sent, if none have been sent already. )rYr[r#timesleep)r%rgrhobjs rr[zRecvChannel.recvsQ nnTXXy1Y JJv ..95CY rc|turtj|jStj|j|S)zReturn the next object from the channel. If none have been sent then return the default if one is provided or fail with ChannelEmptyError. Otherwise this is the same as recv(). )_NOT_SETrYr[r#)r%defaults r recv_nowaitzRecvChannel.recv_nowaits4 h >>$((+ +>>$((G4 4rN)r4rTrUrVobjectr[rnrpr*rrrrs; & #+ 5rrceZdZdZdZdZy)r z/The sending end of a cross-interpreter channel.cntj|j|tjdy)z{Send the object (i.e. its data) to the channel's receiving end. This blocks until the object is received. N)rYr\r#rjrkr%rls rr\zSendChannel.sends# txx% 1 rcBtj|j|S)zSend the object to the channel's receiving end. If the object is immediately received then return True (else False). Otherwise this is the same as send(). )rYr\r#rus r send_nowaitzSendChannel.send_nowaits~~dhh,,rN)r4rTrUrVr\rwr*rrr r s9  -rr )rVrj_xxsubinterpretersr_xxinterpchannelsrYrrrrr__all__r r r r rrrr_rqrnrr r*rrr{s( *%<  . @   4>4>n- 6 85+58-+-r