zRF(dZddlZddlZddlmZmZmZmZgdZdddZ dZ d Z d Z Gd d Z d ZdZGddZeZGddeZGddeZdS)z"Subinterpreters High Level Module.N) ChannelErrorChannelNotFoundErrorChannelEmptyError is_shareable) Interpreter get_currentget_maincreatelist_all SendChannel RecvChannelcreate_channellist_all_channelsrrrrTisolatedcNtj|}t||S)z'Return a new (idle) Python interpreter.r) _interpretersr r)rids @/opt/alt/python311/lib64/python3.11/test/support/interpreters.pyr r s(  x 0 0 0B rH - - --c<dtjDS)z!Return all existing interpreters.c,g|]}t|S)r).0rs r zlist_all..s ? ? ?KOO ? ? ?r)rr rrrr r s ? ?m&<&>&> ? ? ??rcFtj}t|S)z)Return the currently running interpreter.)rrrrs rrr!s  " $ $B r??rcFtj}t|S)zReturn the main interpreter.)rr rrs rr r 's   ! !B r??rcteZdZdZdddZdZdZdZedZ ed Z d Z d Z dd d Z dS)rzA single Python interpreter.Nrct|ttjfst d|||_||_dSNzid must be an int, got ) isinstanceintr InterpreterID TypeError_id _isolated)selfrrs r__init__zInterpreter.__init__0sE"sM$?@AA >z'Interpreter.__repr__..8s08841aQ,,,,888888r(z, ))dictr#r&r'itemstype__name__join)r(datakwargss r__repr__zInterpreter.__repr__6ses48}}t~>>>884::<<888t**%<< &(9(9<<<s)%-- )! !9( (rc|jSr;r&r>s rrzInterpreter.idD xrcZ|jtj|j|_|jSr;)r'r is_isolatedr&r>s rrzInterpreter.isolatedHs( > !+6tx@@DN~rc4tj|jS)zs rrLzInterpreter.is_runningPs'111rc4tj|jS)zFinalize and destroy the interpreter. Attempting to destroy the current interpreter results in a RuntimeError. )rdestroyr&r>s rclosezInterpreter.closeTs $TX...r)channelsc<tj|j||dS)zqRun the given source code in the interpreter. This blocks the current Python thread until done. N)r run_stringr&)r(src_strrPs rrunzInterpreter.run\s!  7H=====r)r5 __module__ __qualname____doc__r)r9r?rEpropertyrrrLrOrTrrrrr-s&&'+""""" === ))) XX222///+/>>>>>>>rrcltj}t|t|}}||fS)zReturn (recv, send) for a new cross-interpreter channel. The channel may be used to pass data safely between interpreters. )rchannel_creater r )cidrecvsends rrrds5  & ( (CS!!;s#3#3$D :rc<dtjDS)z4Return a list of (recv, send) for all open channels.cJg|] }t|t|f!Sr)r r )rr[s rrz%list_all_channels..ps= 9 9 9  {3// 0 9 9 9r)rchannel_list_allrrrrrns, 9 9$577 9 9 99rc@eZdZdZdZdZdZdZedZ dS) _ChannelEndz/The base class for RecvChannel and SendChannel.czt|ttjfst d|||_dSr!)r"r#r ChannelIDr%r&)r(rs rr)z_ChannelEnd.__init__ws>"sM$;<== >s rr9z_ChannelEnd.__repr__|s*t**%;;3tx==;;;;rc*t|jSr;r<r>s rr?z_ChannelEnd.__hash__r@rct|trt|tstSnt|tstS|j|jkSr;)r"r rBr r&rCs rrEz_ChannelEnd.__eq__sX dK ( ( "e[11 &%% &E;// "! !yDH$$rc|jSr;rGr>s rrz_ChannelEnd.idrHrN) r5rUrVrWr)r9r?rErXrrrrrbrbtsq99 <<<%%%Xrrbc:eZdZdZedddZefdZdS)r z1The receiving end of a cross-interpreter channel.g{Gz?) _sentinel_delayctj|j|}||ur2tj|tj|j|}||u2|S)zReturn the next object from the channel. This blocks until an object has been sent, if none have been sent already. )r channel_recvr&timesleep)r(rjrkobjs rr\zRecvChannel.recvs[ (9==Y Jv   ,TXyAACY rcz|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_SETrrmr&)r(defaults r recv_nowaitzRecvChannel.recv_nowaits7 h   -dh77 7 -dh@@ @rN)r5rUrVrWobjectr\rrrtrrrr r s];; &     #+ A A A A A Arr ceZdZdZdZdZdS)r z/The sending end of a cross-interpreter channel.cbtj|j|tjddS)z{Send the object (i.e. its data) to the channel's receiving end. This blocks until the object is received. N)r channel_sendr&rnror(rps rr]zSendChannel.sends, "48S111 1 rc6tj|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(). )rryr&rzs r send_nowaitzSendChannel.send_nowaits)$(C888rN)r5rUrVrWr]r|rrrr r s899    9 9 9 9 9rr )rWrn_xxsubinterpretersrrrrr__all__r r rr rrrrbrurrr r rrrrs(( ****    ..... @@@   4>4>4>4>4>4>4>4>n999 6 688AAAAA+AAA899999+99999r