o =?h@sdZddlZddlZddlmZmZmZmZgdZddddZ d d Z d d Z d dZ GdddZ ddZddZGdddZeZGdddeZGdddeZdS)z"Subinterpreters High Level Module.N) ChannelErrorChannelNotFoundErrorChannelEmptyError is_shareable) Interpreter get_currentget_maincreatelist_all SendChannel RecvChannelcreate_channellist_all_channelsrrrrTisolatedcCstj|d}t||dS)z'Return a new (idle) Python interpreter.r) _interpretersr r)ridr@/opt/alt/python310/lib64/python3.10/test/support/interpreters.pyr s  r cCddtDS)z!Return all existing interpreters.cSsg|]}t|qSr)r).0rrrr szlist_all..)rr rrrrr sr cCt}t|S)z)Return the currently running interpreter.)rrrrrrrr!rcCr)zReturn the main interpreter.)rrrrrrrr'rrc@sleZdZdZddddZddZdd Zd d Zed d Z eddZ ddZ ddZ ddddZ dS)rzA single Python interpreter.NrcCs.t|ttjfstd|||_||_dSNzid must be an int, got ) isinstanceintrZ InterpreterID TypeError_id _isolated)selfrrrrr__init__0s zInterpreter.__init__cCsBtt|j|jd}dd|D}t|jdd|dS)N)rrcss"|] \}}|d|VqdS)=Nr)rkvrrr 8s z'Interpreter.__repr__..(z, ))dictrrr itemstype__name__join)r!datakwargsrrr__repr__6szInterpreter.__repr__cC t|jSNhashrr!rrr__hash__; zInterpreter.__hash__cCst|tstS|j|jkSr2)rrNotImplementedrr!otherrrr__eq__>s  zInterpreter.__eq__cC|jSr2rr5rrrrDzInterpreter.idcCs|jdur t|j|_|jSr2)r rZ is_isolatedrr5rrrrHs zInterpreter.isolatedcC t|jS)z.)rZchannel_list_allrrrrrnsrc@s<eZdZdZddZddZddZdd Zed d Z d S) _ChannelEndz/The base class for RecvChannel and SendChannel.cCs(t|ttjfstd|||_dSr)rrrZ ChannelIDrr)r!rrrrr"ws z_ChannelEnd.__init__cCst|jdt|jdS)Nz(id=r()r+r,rrr5rrrr0|sz_ChannelEnd.__repr__cCr1r2r3r5rrrr6r7z_ChannelEnd.__hash__cCs4t|tr t|ts tSnt|tstS|j|jkSr2)rr r8r rr9rrrr;s    z_ChannelEnd.__eq__cCr<r2r=r5rrrrr>z_ChannelEnd.idN) r,rDrErFr"r0r6r;rGrrrrrrKtsrKc@s.eZdZdZeddddZefddZdS) r z1The receiving end of a cross-interpreter channel.g{Gz?) _sentinel_delaycCs:t|j|}||urt|t|j|}||us |S)zReturn the next object from the channel. This blocks until an object has been sent, if none have been sent already. )r channel_recvrtimesleep)r!rLrMobjrrrrIs  zRecvChannel.recvcCs"|tur t|jSt|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_SETrrNr)r!defaultrrr recv_nowaits zRecvChannel.recv_nowaitN)r,rDrErFobjectrIrRrTrrrrr s r c@s eZdZdZddZddZdS)r z/The sending end of a cross-interpreter channel.cCst|j|tddS)z{Send the object (i.e. its data) to the channel's receiving end. This blocks until the object is received. N)r channel_sendrrOrPr!rQrrrrJszSendChannel.sendcCst|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(). )rrWrrXrrr send_nowaits zSendChannel.send_nowaitN)r,rDrErFrJrYrrrrr s r )rFrOZ_xxsubinterpretersrrrrr__all__r r rrrr rrKrUrRr r rrrrs  7