+
    Bi                        ^ RI Ht ^ RIt^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RI	H
t
Ht ]
P                  ! R4      t^ RIHt ^ RIHtHtHt ]P(                  ]P*                  ,          tR tR	R
/R ltR t/ 3R lt ! R R]! RR4      4      t]P8                  R 4       t ! R R]! RR4      4      t ! R R]! RR4      4      tRR/R lt R t!R t" ! R R]PF                  4      t$ ! R R ]$4      t%]! R!RR"7       ! R# R$]$4      4       t& ! R% R&]$4      t' ! R' R(]! R(R)4      4      t(]PR                  ! R*4       ! R+ R,]$4      4       t*]+R-8X  d   ]PX                  ! 4        R# R# ).    )
namedtupleN)dedent)import_helperskip_if_sanitizer_interpchannels)_crossinterp)_interpreters_run_outputclean_up_interpretersc                       \         P                  V 4      w  rVe   Q \        V4      4       hV#   \         P                   d    \        P
                  ! R4        K]  i ; i)T皙?)	_channelsrecvreprChannelEmptyErrortimesleep)cidobj	unboundops   &  0/usr/lib/python3.14/test/test__interpchannels.py	recv_waitr      sX    
	&^^C0NC $5d9o5$J	 ** 	JJsO	s   0 +AAunboundFc                l    \         P                  ! V .VO5!  w  r4VR J V8w  g   Q \        V4      4       hV# N)r   r   r   )r   r   argsr   r   s   &$*  r   recv_nowaitr   *   s8    ^^C/$/NC'):4	?:)J    c                     \        WV4       R # r   )_run_interp)idsourceshareds   &&,r   
run_interpr$   :   s    F#r   c                     \        V4      p\        P                  ! 4       vrEW@8X  d0   \        P                  ! 4       vreWd8w  d   \        h\        W4       R # \        P                  ! WV4       R # r   )r   r	   get_mainget_currentRuntimeErrorexec
run_string)r!   r"   r#   _mainnsmain_curs   &&&&   r   r    r    >   sS    F^F%%'HDz++-;V  V4r   c                   F   a a ] tR t^Kt o]R 4       tRV 3R lltRtVtV ;t	# )Interpreterc                p    \        W4      '       d   V# \        V\        4      '       d	   V ! V4      # \        hr   )
isinstancestrNotImplementedError)clsraws   &&r   from_rawInterpreter.from_rawM   s.    cJS!!s8O%%r   c                  < \         P                  ! 4       vr4W#8X  d0   V'       g   R pM!VR 8w  d   \        RP                  V4      4      hTpMqVeE   V'       g   RpMVR 8X  d   \        R4      h\	        V\
        4      '       g   Q \        V4      4       hM)V'       d   VR 8X  d   R pTpM\         P                  ! 4       p\        SV `%  WV4      pV# )r,   z)name mismatch (expected "main", got "{}")interpz!name mismatch (unexpected "main"))
r	   r&   
ValueErrorformatr2   intr   createsuper__new__)r5   namer!   r,   r-   self	__class__s   &&&   r   r@   Interpreter.__new__V   s     ))+: ?FFtLN NB^ !DEEb#&&0R0&DB%%'Bws"-r    NN)
__name__
__module____qualname____firstlineno__classmethodr7   r@   __static_attributes____classdictcell____classcell__rC   __classdict__s   @@r   r0   r0   K   s!     & & r   r0   zname idc               #   Z   "    R x  Q R4       h  \         P                   d     R # i ; i5i)Nzchannel not closed)r   ChannelClosedErrorrE   r   r   expect_channel_closedrS   p   s3     + 	+**u '' s   + +(+(+c                   H   a a ] tR t^zt oRV 3R lltR tR tR tRtVt	V ;t
# )ChannelActionc                P   < V'       g   R pV'       g   Rp\         SV `  WW#4      pV# )bothr,   r?   r@   )r5   actionendr:   rB   rC   s   &&&& r   r@   ChannelAction.__new__|   s(    CFwsC8r   c                \   V P                   R 8X  d(   V P                  R9  d   \        V P                  4      hMMV P                   R9   d(   V P                  R9  d   \        V P                  4      hM\        V P                   4      hV P                  R9  d   \        V P                  4      hR# )useNsameoppositesendr   closeforce-close)rW   r_   r`   ra   r   )r,   r_   otherextra)rY   rZ   r;   r:   )rB   r   kwargss   &*,r   __init__ChannelAction.__init__   s    ;;%xxCC ** D[[44xxKK ** L T[[));;@@T[[)) Ar   c                x    V P                   R 8X  d   V# V P                   R8X  d   VR8X  d   R# R# V P                   # r^   rZ   rB   rZ   s   &&r   resolve_endChannelAction.resolve_end   s9    88vJXX# F]66688Or   c                *   V P                   R 8X  d   V# V P                   R8X  d   Vf   \        hV# V P                   R8X  d   Vf   \        hV# V P                   R8X  d5   VP                  R8X  d   V# V'       d   VP                  R8X  d   V# \        hR# )r_   re   Nrf   r,   )r:   r(   rA   )rB   r:   re   rf   s   &&&&r   resolve_interpChannelAction.resolve_interp   s    ;;& M[[G#}""L[[G#}""L[[F"{{f$5::/"" #r   rE   rF   )rG   rH   rI   rJ   r@   rh   rm   rp   rL   rM   rN   rO   s   @@r   rU   rU   z   s     
*# #r   rU   zaction end interpc                   X   a a ] tR t^t oR
RR/V 3R llltR tR tRR/R ltR	tVt	V ;t
# )ChannelStateclosedFc               (   < \         SV `  WV4      pV# r   rX   )r5   pendingrt   rB   rC   s   &&$ r   r@   ChannelState.__new__   s    wsV4r   c                ^    \        V 4      ! V P                  ^,           V P                  R7      #    rt   typerv   rt   rB   s   &r   incrChannelState.incr        Dz$,,*4;;??r   c                ^    \        V 4      ! V P                  ^,
          V P                  R7      # ry   r|   r~   s   &r   decrChannelState.decr   r   r   forceTc                   V P                   '       d   V'       d   V P                  ^ 8X  d   V # \        V 4      ! V'       d	   ^ RR7      # V P                  RR7      # )r   Tr{   )rt   rv   r}   )rB   r   s   &$r   rc   ChannelState.close   s?    ;;;DLLA-Dzu!tDD$,,tDDr   rE   )r   )rG   rH   rI   rJ   r@   r   r   rc   rL   rM   rN   rO   s   @@r   rs   rs      s6     %  @@ET E Er   rs   zpending closed
hideclosedTc                $   VP                   '       d'   VR 8X  d   VR8X  d   VP                  '       d   RpMRpMRp \        WW#4      pV'       d   Rh V#   \        P                   d&    T'       g
   T'       g   h TP                  4       p T# i ; i)r]   r   FT.)rt   rv   _run_actionr   rR   rc   )r   rY   rZ   stater   
expectfailresults   &&&&$  r   
run_actionr      s    |||U?sf}JJ
S#5 I M '' * Ms   A B2B:BBc                 r   VR 8X  d   VR8X  d)   \         P                  V RRR7       VP                  4       # VR8X  dO   VP                  '       g"    \         P	                  V 4       \        R4      h\        V 4       VP                  4       # \        V4      hVR8X  d5   / pVR9   d   RWB&   \         P                  ! V 3/ VB  VP                  4       # VR	8X  d9   R
R/pVR9   d   RWB&   \         P                  ! V 3/ VB  VP                  RR7      # \        V4      h  \         P                   d    Tu # i ; i)r]   ra      spamFblockingr   zexpected ChannelEmptyErrorrc   Trd   r   r   r   ra   )r   ra   r   rv   r   	Exceptionr   r   r   r;   rc   )r   rY   rZ   r   rg   s   &&&& r   r   r      s%   &=NN3%N8::<F]===BNN3' $$@AAC zz|#S/!	7	""FK&v&{{}	=	 T ""FK&v&{{{&&  1 !22 ! L!s   D D65D6c                      \         P                  4        F  w  p  p \         P                  V 4       K  	  R #   \         P                   d     K;  i ; ir   )r   list_alldestroyChannelNotFoundError)r   r-   s     r   clean_up_channelsr      sH    '')	Q	c" * -- 		s   8AAc                   &   a  ] tR tRt o R tRtV tR# )TestBasei  c                .    \        4        \        4        R # r   )r   r   r~   s   &r   tearDownTestBase.tearDown  s    r   rE   N)rG   rH   rI   rJ   r   rL   rM   rP   s   @r   r   r     s        r   r   c                   \   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )ChannelIDTestsi  c                    \         P                  ^
RR7      pV P                  \        V4      ^
4       V P                  VP                  R4       R# )
   Tr   rW   N)r   _channel_idassertEqualr=   rZ   rB   r   s   & r   test_default_kwargs"ChannelIDTests.test_default_kwargs  s?    ##Bd#3S2&&)r   c                   \         P                  ^
RRR7      pV P                  VP                  R4       \         P                  ^
RRRR7      pV P                  VP                  R4       \         P                  ^
RRR7      pV P                  VP                  R4       \         P                  ^
RRRR7      pV P                  VP                  R4       \         P                  ^
RRRR7      pV P                  VP                  R	4       R
# )r   Tra   r   ra   Fra   r   r   r   r   r   )r   ra   r   rW   N)r   r   r   rZ   r   s   & r   test_with_kwargsChannelIDTests.test_with_kwargs  s    ##BT#>&)##BTT#J&)##BT#>&)##BTT#J&)##BTD#I&)r   c                     ! R  R\         4      p\        P                  V! 4       RR7      pV P                  \	        V4      ^
4       R# )c                   &   a  ] tR tRt o R tRtV tR# )*ChannelIDTests.test_coerce_id.<locals>.Inti$  c                    ^
# )r   rE   r~   s   &r   	__index__4ChannelIDTests.test_coerce_id.<locals>.Int.__index__%  s    r   rE   N)rG   rH   rI   rJ   r   rL   rM   r   s   @r   Intr   $  s      r   r   Tr   N)r3   r   r   r   r=   )rB   r   r   s   &  r   test_coerce_idChannelIDTests.test_coerce_id#  s;    	# 	 ##CE#6S2&r   c                   V P                  \        \        P                  \	        4       4       V P                  \        \        P                  R 4       V P                  \        \        P                  R4       V P                  \        \        P                  R4       V P                  \
        \        P                  R4       V P                  \        \        P                  R4       R# )g      $@10s   10Nl            )assertRaises	TypeErrorr   r   objectr;   OverflowErrorr~   s   &r   test_bad_idChannelIDTests.test_bad_id+  s    )Y%:%:FHE)Y%:%:DA)Y%:%:DA)Y%:%:EB*i&;&;R@-)>)>Fr   c                    V P                  \        4      ;_uu_ 4        \        P                  ^
RRR7       RRR4       R#   + '       g   i     R# ; i)r   Fra   r   N)r   r;   r   r   r~   s   &r   test_bad_kwargsChannelIDTests.test_bad_kwargs3  s7    z**!!"5u!= +***s   AA	c                
   \         P                  \        4      pV P                  \         P                  4      ;_uu_ 4        \         P                  \        V4      ^,           4       RRR4       R#   + '       g   i     R# ; irz   N)r   r>   REPLACEr   r   r   r=   r   s   & r   test_does_not_exist"ChannelIDTests.test_does_not_exist7  sN    w'y==>>!!#c(Q,/ ?>>>s   &A11B	c                j    \         P                  ^
RR7      pV P                  \        V4      R4       R# )r   Tr   r   N)r   r   r   r3   r   s   & r   test_strChannelIDTests.test_str<  s+    ##Bd#3S4(r   c                   \         P                  ^
RR7      pV P                  \        V4      R4       \         P                  ^
RRR7      pV P                  \        V4      R4       \         P                  ^
RRR7      pV P                  \        V4      R4       \         P                  ^
RRRR7      pV P                  \        V4      R4       R	# )
r   Tr   zChannelID(10)r   zChannelID(10, send=True)r   zChannelID(10, recv=True)r   N)r   r   r   r   r   s   & r   	test_reprChannelIDTests.test_repr@  s    ##Bd#3cO4##BT#>c$>?##BT#>c$>?##BTD#IcO4r   c                   \         P                  \        4      p\         P                  \	        V4      4      p\         P                  \        4      pV P                  W8H  4       V P                  W8H  4       V P                  V\	        V4      8H  4       V P                  \	        V4      V8H  4       V P                  V\        \	        V4      4      8H  4       V P                  \        \	        V4      4      V8H  4       V P                  V\        \	        V4      4      R ,           8H  4       V P                  V\        \	        V4      4      8H  4       V P                  V^R,          8H  4       V P                  V\        R4      8H  4       V P                  VR8H  4       V P                  W8H  4       V P                  W8g  4       V P                  W8g  4       V P                  W8g  4       R# )r     infspamN)	r   r>   r   r   r=   
assertTruefloatassertFalser3   )rB   cid1cid2cid3s   &   r   test_equalityChannelIDTests.test_equalityM  si   ($$SY/(%%D	)*D	T)*c$i 001c$i(D01s4y!1C!778SY/0D)u-.(&&&%r   c                   \         P                  \        4      p\         P                  \        4      p\         P                  WR R7       \	        V4      pV P                  W24       V P                  \        V4      \        V4      4       R# )Fr   N)r   r>   r   ra   r   r   assertIsr}   )rB   chanr   gots   &   r   test_shareableChannelIDTests.test_shareablec  s`    (w't51$"d3ic+r   rE   N)rG   rH   rI   rJ   r   r   r   r   r   r   r   r   r   r   rL   rM   r   s   @r   r   r     s=     ** 'G>0
)5&,, ,r   r   z#gh-129824: race on _waiting_release)threadc                   x  a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR t]P"                  ! R4      R 4       tR tR tR tR tR tR tR tR tR tR tR tRR/R ltR tR t R  t!R! t"R" t#R# t$R$ t%R% t&R& t'R' t(R( t)R) t*R* t+R+ t,R, t-R- t.R. t/R/ t0R0 t1R1 t2R2 t3R3 t4R4 t5R5 t6R6t7V t8R7# )8ChannelTestsip  c                x    \         P                  \        4      pV P                  V\         P                  4       R # r   )r   r>   r   assertIsInstance	ChannelIDr   s   & r   test_create_cidChannelTests.test_create_cids  s(    w'c9#6#67r   c                6   \         P                  4        UUu. uF  w  p q!NK
  	  ppp\         P                  \        4      p\         P                  \        4      p\         P                  \        4      p\         P                  4        UUu. uF  w  p q!NK
  	  pppV P	                  V\        V4      ^,           4       V P	                  V\        V4      ^,           4       V P	                  \        V4      \        V4      ,
          WEV04       R# u uppi u uppi r   )r   r   r>   r   r   r=   set)rB   r   r-   beforeid1id2id3afters   &       r   test_sequential_ids ChannelTests.test_sequential_idsw  s    '0'9'9';<';)#q!#';<w'w'w'&/&8&8&:;&:a&:;c#hl+c#hl+Uc&k1Cc?C = <s   DDc                V   \         P                  ! 4       p\        V\        R 4      4      p\	        VP                  4       4      p\         P                  ! 4       p\        V\        R 4      4      p\	        VP                  4       4      pV P                  V\	        V4      ^,           4       R# )zz
            import _interpchannels as _channels
            cid = _channels.create(3)
            print(cid)
            N)r	   r>   r
   r   r=   stripr   )rB   r   outr   r   r   s   &     r   test_ids_globalChannelTests.test_ids_global  s    ""$#v '   
 399;""$#v '   
 399;s4y1}-r   c                    \         P                  \        4      p\         P                  VRR7      p\         P                  VRR7      pV P	                  V. 4       V P	                  V. 4       R# )z=Test listing interpreters for a channel with no associations.Tra   FN)r   r>   r   list_interpretersr   )rB   r   send_interpsrecv_interpss   &   r   #test_channel_list_interpreters_none0ChannelTests.test_channel_list_interpreters_none  s^     w' 223T2B 223U2Cr*r*r   c                8   \         P                  ! 4       vr\        P                  \        4      p\        P                  VRRR7       \        P                  VRR7      p\        P                  VRR7      pV P                  WA.4       V P                  V. 4       \         P                  ! 4       p\        V\        RV R24      4       \        P                  VRR7      p\        P                  VRR7      pV P                  WA.4       V P                  WV.4       R# )	z)Test basic listing channel _interpreters.ra   Fr   Tr   L
            import _interpchannels as _channels
            _channels.recv()
            N)
r	   r&   r   r>   r   ra   r   r   r
   r   )rB   interp0r-   r   r   r   interp1s   &      r   $test_channel_list_interpreters_basic1ChannelTests.test_channel_list_interpreters_basic  s    #,,.w'sFU3 223T2B 223U2Cy1r*&&(GV )5 !%  	
 !223T2B 223U2Cy1y1r   c                t   \         P                  ! 4       vr\         P                  ! 4       p\         P                  ! 4       p\         P                  ! 4       p\        P                  \        4      p\        P                  VRRR7       \        V\        RV R24      4       \        V\        RV R24      4       \        V\        RV R24      4       \        P                  VRR	7      p\        P                  VRR	7      pV P                  \        V4      W04       V P                  \        V4      WE04       R
# )z?Test listing interpreters for a channel with many associations.ra   Fr   L
            import _interpchannels as _channels
            _channels.send(z&, "send", blocking=False)
            r  r  Tr   N)r	   r&   r>   r   r   ra   r
   r   r   r   r   )	rB   r  r-   r  interp2interp3r   r   r   s	   &        r   'test_channel_list_interpreters_multiple4ChannelTests.test_channel_list_interpreters_multiple  s-   #,,.&&(&&(&&(w'sFU3GV )5 !%  	 	GV )5 !%  	 	GV )5 !%  	 !223T2B 223U2C\*W,>?\*W,>?r   c                d   \         P                  ! 4       vr\         P                  ! 4       p\        P                  \        4      p\        P                  VRRR7       \        V\        RV R24      4       \        P                  VRR7      p\        P                  VRR7      pV P                  WQ.4       V P                  Wc.4       \         P                  ! V4       \        P                  VRR7      p\        P                  VRR7      pV P                  WQ.4       V P                  V. 4       R# )	z?Test listing channel interpreters with a destroyed interpreter.ra   Fr   r  r  Tr   N)r	   r&   r>   r   r   ra   r
   r   r   r   r   rB   r  r-   r  r   r   r   s   &      r   (test_channel_list_interpreters_destroyed5ChannelTests.test_channel_list_interpreters_destroyed  s   #,,.&&(w'sFU3GV )5 !%  	
 !223T2B 223U2Cy1y1g& 223T2B 223U2Cy1r*r   c                "   \         P                  ! 4       vr\         P                  ! 4       p\         P                  ! 4       p\        P                  \        4      p\        P                  VRRR7       \        V\        RV R24      4       \        P                  VRRR7       \        V\        RV R24      4       \        P                  VRR7      p\        P                  VRR7      pV P                  \        V4      ^4       V P                  \        V4      ^4       \        P                  VRR7       \        P                  VRR7      p\        P                  VRR7      pV P                  \        V4      ^ 4       V P                  \        V4      ^4       \        V\        RV R24      4       \        P                  VRR7      p\        P                  VRR7      pV P                  \        V4      ^ 4       V P                  Ws.4       R	# )
z:Test listing channel interpreters with a released channel.dataFr   r  r  Tr   O
            import _interpchannels as _channels
            _channels.release(N)r	   r&   r>   r   r   ra   r
   r   r   r   lenrelease)rB   r  r-   r  r	  r   r   r   s   &       r   'test_channel_list_interpreters_released4ChannelTests.test_channel_list_interpreters_released  s    $,,.&&(&&(w'sFU3GV )5 !%  	 	sFU3GV )5 !%  	
 !223T2B 223U2C\*A.\*A. 	#D) 223T2B 223U2C\*A.\*A. 	GV )"e $%  	
 !223T2B 223U2C\*A.y1r   c                   \         P                  ! 4       vr\         P                  ! 4       p\        P                  \        4      p\        P                  VRRR7       \        P                  VRR7      p\        P                  VRR7      pV P                  \        V4      ^4       V P                  \        V4      ^ 4       \        P                  VRR7       V P                  \        P                  4      ;_uu_ 4        \        P                  VRR7       RRR4       V P                  \        P                  4      ;_uu_ 4        \        P                  VRR7       RRR4       R#   + '       g   i     LY; i  + '       g   i     R# ; i)z8Test listing channel interpreters with a closed channel.ra   Fr   Tr   r   N)r	   r&   r>   r   r   ra   r   r   r  rc   r   rR   r  s   &      r   %test_channel_list_interpreters_closed2ChannelTests.test_channel_list_interpreters_closed  s   #,,.&&(w'sFU3 !223T2B 223U2C\*A.\*A. 	4(y;;<<''$'7 =y;;<<''%'8 =< =<<<<s   ?E(E;(E8	;F	c                   \         P                  ! 4       vr\         P                  ! 4       p\        P                  \        4      p\        P                  VRRR7       \        P                  VRR7      p\        P                  VRR7      pV P                  \        V4      ^4       V P                  \        V4      ^ 4       \        P                  VRR7       V P                  \        P                  4      ;_uu_ 4        \        P                  VRR7       RRR4       \        P                  VRR7      pV P                  \        V4      ^ 4       \        V\        RV R24      4       R#   + '       g   i     L]; i)	zCTest listing channel interpreters with a channel's send end closed.ra   Fr   Tr   NM
            import _interpchannels as _channels
            _channels.close(, force=True)
            )r	   r&   r>   r   r   ra   r   r   r  rc   r   rR   r
   r   r  s   &      r   .test_channel_list_interpreters_closed_send_end;ChannelTests.test_channel_list_interpreters_closed_send_end&  s:   #,,.&&(w'sFU3 !223T2B 223U2C\*A.\*A. 	$'y;;<<''$'7 = !223U2C\*A. 	GV ) E "%  	 	 =<s   ?E,,E<	c           	     l   \         P                  \        4      p. ROpV F|  pV P                  V4      ;_uu_ 4        \         P	                  WRR7       \        V4      pV P                  WC4       V P                  \        V4      \        V4      4       R R R 4       K~  	  R #   + '       g   i     K  ; i)NFr   )Nr   r   *   )	r   r>   r   subTestra   r   r   r   r}   )rB   r   objectsr   r   s   &    r   test_allowed_typesChannelTests.test_allowed_typesI  s    w'
 Cc""s%8!#&  *d3ic3 #" """s   AB""B3c                \   \         P                  \        4      p\        P                  ! 4       p\        P                  ! V\        VP                  R 7      4       \        V\        R4      4      p\        V4      pV P                  VR4       V P                  VP                  4       R4       R# )r   z
            import _interpchannels as _channels
            print(cid.end)
            _channels.send(cid, b'spam', blocking=False)
            r   ra   N)r   r>   r   r	   set___main___attrsdictra   r
   r   r   r   r   rB   r   r:   r   r   s   &    r   test_run_string_arg_unresolved+ChannelTests.test_run_string_arg_unresolved\  s    w'%%'((#((1CD&& * # 
 #g&f-r   z(disabled until high-level channels existc                ^   \         P                  \        4      p\         P                  VR R7      p\        P                  ! 4       p\        V\        R4      \        VP                  R7      4      p\        V4      pV P                  VR4       V P                  VP                  4       R4       R# )T)_resolvez
            import _interpchannels as _channels
            print(chan.id.end)
            _channels.send(chan.id, b'spam', blocking=False)
            )r   r   ra   N)r   r>   r   r   r	   r
   r   r)  ra   r   r   r   r*  s   &    r   test_run_string_arg_resolved)ChannelTests.test_run_string_arg_resolvedn  s    w'##C$#7%%'&& * #
 chh! #g&f-r   c                    \         P                  \        4      pR p\         P                  WRR7       \	        V4      pV P                  W24       V P                  W24       R# r   Fr   N)r   r>   r   ra   r   r   assertIsNot)rB   r   origr   s   &   r   test_send_recv_main ChannelTests.test_send_recv_main  sM    w's51###r   c                Z    \         P                  ! 4       p\        V\        R 4      4      pR# )a%  
            import _interpchannels as _channels
            cid = _channels.create(REPLACE)
            orig = b'spam'
            _channels.send(cid, orig, blocking=False)
            obj, _ = _channels.recv(cid)
            assert obj is not orig
            assert obj == orig
            N)r	   r>   r
   r   )rB   r   r   s   &  r   test_send_recv_same_interpreter,ChannelTests.test_send_recv_same_interpreter  s(    ""$#v '   r   c                    \         P                  \        4      p\        P                  ! 4       p\	        V\        R V R24      4      p\        V4      pV P                  VR4       R# )r  ', b'spam', blocking=False)
            r   N)r   r>   r   r	   r
   r   r   r   )rB   r   r   r   r   s   &    r   %test_send_recv_different_interpreters2ChannelTests.test_send_recv_different_interpreters  sc    w'""$#v +5 !'    #g&r   c                  a \         P                  \        4      oV3R  lp\        P                  ! VR7      pVP                  4        \         P                  SR4       \        S4      pVP                  4        V P                  VR4       R# )c                  J   < \        S4      p \        P                  SV 4       R # r   )r   r   ra   )r   r   s    r   f8ChannelTests.test_send_recv_different_threads.<locals>.f  s    C.CNN3$r   targetr   N)
r   r>   r   	threadingThreadstartra   r   joinr   )rB   r@  tr   r   s   &   @r    test_send_recv_different_threads-ChannelTests.test_send_recv_different_threads  sc    w'	% A&		sG$n	g&r   c                P  aaa \         P                  \        4      o\        P                  ! 4       oR oVVV3R lp\        P
                  ! VR7      pVP                  4        \         P                  SR4       \        S4      pVP                  4        V P                  VR4       R # )Nc            
      @   < \        S\        R S  RS  R24      4      oR# )z
                import time
                import _interpchannels as _channels
                while True:
                    try:
                        obj, _ = _channels.recv(z)
                        break
                    except _channels.ChannelEmptyError:
                        time.sleep(0.1)
                assert(obj == b'spam')
                _channels.send(z, b'eggs')
                N)r
   r   )r   r   r   s   r   r@  IChannelTests.test_send_recv_different_interpreters_and_threads.<locals>.f  s8    c6 /1
 25 6 
 !$u %+ $ Cr   rB  r      eggs)r   r>   r   r	   rD  rE  rF  ra   r   rG  r   )rB   r@  rH  r   r   r   r   s   &   @@@r   1test_send_recv_different_interpreters_and_threads>ChannelTests.test_send_recv_different_interpreters_and_threads  sv    w'""$	 A&		sG$n	g&r   c                    V P                  \        P                  4      ;_uu_ 4        \        P                  ^
R4       RRR4       R#   + '       g   i     R# ; i)r   r   N)r   r   r   ra   r~   s   &r   test_send_not_found ChannelTests.test_send_not_found  s6    y==>>NN2w' ?>>>s   A		A	c                    V P                  \        P                  4      ;_uu_ 4        \        P                  ^
4       RRR4       R#   + '       g   i     R# ; i)r   N)r   r   r   r   r~   s   &r   test_recv_not_found ChannelTests.test_recv_not_found  s4    y==>>NN2 ?>>>s   AA	c                    \         P                  \        4      pV P                  \         P                  4      ;_uu_ 4        \         P                  V4       R R R 4       R #   + '       g   i     R # ; ir   )r   r>   r   r   r   r   r   s   & r   test_recv_emptyChannelTests.test_recv_empty  sD    w'y::;;NN3 <;;;s   A!!A2	c                d   \        4       p\        P                  \        4      p\	        W!4      p\        P                  VR RR7       \        P                  V^RR7       \        P                  VRRR7       \        P                  VRRR7       \	        W!4      p\	        W!4      p\	        V4      p\	        W!4      p\	        W!4      pV P                  W14       V P                  VR 4       V P                  V^4       V P                  VR4       V P                  VR4       V P                  W4       R # )NFr   r   rN  )r   r   r>   r   r   ra   r   r   )	rB   defaultr   obj1obj2obj3obj4obj5obj6s	   &        r   test_recv_defaultChannelTests.test_recv_default  s    (w'3(sD51sA.sGe4sGe43(3(33(3(d$dD!q!w'w'd$r   c           
     4   V P                  R 4      ;_uu_ 4        \        P                  \        4      p\        P                  ! 4       p\        P
                  ! V\        RV R24      4       \        P                  ! V4       V P                  \        RV R24      ;_uu_ 4        \        P                  V4       RRR4       ?RRR4       V P                  R4      ;_uu_ 4        \        P                  \        4      p\        P                  ! 4       p\        P
                  ! V\        RV R24      4       \        P                  VRRR	7       \        P                  ! V4       \        VR
R7       \        VRR7       V P                  \        RV R24      ;_uu_ 4        \        P                  V4       RRR4       ?RRR4       R#   + '       g   i     EL; i  + '       g   i     EL$; i  + '       g   i     LC; i  + '       g   i     R# ; i)rt   zT
                import _interpchannels as _channels
                _channels.send(z+, b'spam', blocking=False)
                zchannel z
 is closedNz
still openrN  Fr   T)r   z	 is empty)r"  r   r>   r   r	   r*   r   r   assertRaisesRegexr(   r   ra   r   )rB   r   r:   r   s   &   r   "test_recv_sending_interp_destroyed/ChannelTests.test_recv_sending_interp_destroyed  s   \\(####G,D"))+F$$VV 9  $v &5 .  !!&)''*24&
(CE Et$E  $ \\,''##G,D"))+F$$VV 9  $v &5 .  NN45N9!!&)d+e,''*24&	(BD Dt$D  ('	E E E $##2D D (''sI   BG%G	;	G%B=H"G3	8	HG	GG0	3H>HH	c                Z   \        R 4      p\        P                  \        4      p\        P	                  W!RR7       \        V4      pV P                  W14       V P                  V\        4       V P                  W14       RVR&   V P                  W14       RVR&   V P                  W14       R# )s   spamspamspamFr   rN  :      Ns   ham.N)
	bytearrayr   r>   r   send_bufferr   r3  r   
memoryviewr   )rB   bufr   r   s   &   r   test_send_bufferChannelTests.test_send_buffer  s    (w'c7#"c:."C"C"r   bufferFc                 a V'       d   \         P                  pM\         P                  p\         P                  \        4      p \
        P                  ! 4       pV! WAR R7       \
        P                  ! 4       p\        V4       \         P                  V4       We,
          oS^,          oV3R lpV#   \         P                  T4       i ; i)Fr   c                  4   < \         P                  ! S 4       R # r   )r   r   )delays   r   wait,ChannelTests.build_send_waiter.<locals>.wait6  s    JJur   )	r   rl  ra   r>   r   r   	monotonicr   r   )	rB   r   rq  ra   r   startedstoppedru  rt  s	   &&$     @r   build_send_waiterChannelTests.build_send_waiter#  s     ((D>>Dw'	#nn&GE*nn&Gc"!
	 c"s   ?B2 2C	c                :  aaa R oRpV P                  V4      o\        P                  \        4      oVVV3R lp\        P
                  ! VR7      pVP                  4        \        P                  SVRR7       VP                  4        V P                  SV4       R # )Nr   c                  ,   < S! 4        \        S 4      oR # r   r   r   receivedru  s   r   r@  2ChannelTests.test_send_blocking_waiting.<locals>.f?      F ~Hr   rB  Tr   )
rz  r   r>   r   rD  rE  rF  ra   rG  r   rB   r   r@  rH  r   r  ru  s   &   @@@r   test_send_blocking_waiting'ChannelTests.test_send_blocking_waiting:  sx    %%c*w'	& A&		sC$/	3'r   c                P  aaa R o\        R4      pV P                  VRR7      o\        P                  \        4      oVVV3R lp\
        P                  ! VR7      pVP                  4        \        P                  SVRR7       VP                  4        V P                  SV4       R # )Nr   Trq  c                  ,   < S! 4        \        S 4      oR # r   r~  r  s   r   r@  9ChannelTests.test_send_buffer_blocking_waiting.<locals>.fO  r  r   rB  r   )rk  rz  r   r>   r   rD  rE  rF  rl  rG  r   r  s   &   @@@r   !test_send_buffer_blocking_waiting.ChannelTests.test_send_buffer_blocking_waitingJ  s     %%c$%7w'	& A&		c36	3'r   c                  aa R oRp\         P                  \        4      oVV3R lp\        P                  ! VR7      pVP                  4        \         P                  SVRR7       VP                  4        V P                  SV4       R # )Nr   c                     < \        S 4      oR # r   r~  r   r  s   r   r@  2ChannelTests.test_send_blocking_no_wait.<locals>.f^       ~Hr   rB  Tr   )	r   r>   r   rD  rE  rF  ra   rG  r   rB   r   r@  rH  r   r  s   &   @@r   test_send_blocking_no_wait'ChannelTests.test_send_blocking_no_waitZ  sh    w'	& A&		sC$/	3'r   c                &  aa R o\        R4      p\        P                  \        4      oVV3R lp\        P
                  ! VR7      pVP                  4        \        P                  SVRR7       VP                  4        V P                  SV4       R # )Nr   c                     < \        S 4      oR # r   r~  r  s   r   r@  9ChannelTests.test_send_buffer_blocking_no_wait.<locals>.fl  r  r   rB  Tr   )
rk  r   r>   r   rD  rE  rF  rl  rG  r   r  s   &   @@r   !test_send_buffer_blocking_no_wait.ChannelTests.test_send_buffer_blocking_no_waith  sp     w'	& A&		c36	3'r   c                  a R pV P                  R4      ;_uu_ 4        \        P                  \        4      oV P	                  \
        4      ;_uu_ 4        \        P                  SVRRR7       RRR4       RRR4       V P                  R4      ;_uu_ 4        \        P                  \        4      oV P	                  \        4      ;_uu_ 4        \        P                  SVRRR7       RRR4       V P	                  \        P                  4      ;_uu_ 4        \        S4      p\        \        V4      4       RRR4       RRR4       V P                  R4      ;_uu_ 4        \        P                  \        4      oV3R	 lp\        P                  ! VR
7      pVP                  4        \        P                  SVR^
R7       VP                  4        RRR4       R#   + '       g   i     ELu; i  + '       g   i     EL; i  + '       g   i     EL#; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)r   non-blocking with timeoutFr   r   timeoutNtimeout hitTtimeout not hitc                     < \        S 4       R # r   r~  r'  s   r   r@  )ChannelTests.test_send_timeout.<locals>.f  
    #r   rB  )r"  r   r>   r   r   r;   ra   TimeoutErrorr   r   printr   rD  rE  rF  rG  rB   r   r  r@  rH  r   s   &    @r   test_send_timeoutChannelTests.test_send_timeoutv  s   \\566""7+C"":..sC%E / 7
 \\-((""7+C""<00sC$D 1""9#>#>??&s+d8n% @	 ) \\+,,""7+C  *AGGINN3dBN?FFH -, /.. 766 100??	 )( -,,sl   7G.G	.G.7H)H	(/H) H	7H) A0H<G+%	G..G?	H	H)H&!H))H9	<I	c                (  a  V P                    R V n         \	        R4      pT P                  R4      ;_uu_ 4        \        P                  \        4      oT P                  \        4      ;_uu_ 4        \        P                  STRRR7       RRR4       RRR4       T P                  R4      ;_uu_ 4        \        P                  \        4      oT P                  \        4      ;_uu_ 4        \        P                  STR RR7       RRR4       T P                  \        P                  4      ;_uu_ 4        \        S4      p\        \!        T4      4       RRR4       RRR4       T P                  R	4      ;_uu_ 4        \        P                  \        4      oT3R
 lp\"        P$                  ! TR7      pTP'                  4        \        P                  STR ^
R7       TP)                  4        RRR4       R#   \         d    \        P                  ! R4      hi ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELH; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i)T#temporarily skipped due to refleaksr   r  Fr   r  Nr  r  c                     < \        S 4       R # r   r~  r'  s   r   r@  0ChannelTests.test_send_buffer_timeout.<locals>.f  r  r   rB  )_has_run_once_timeoutAttributeErrorunittestSkipTestrk  r"  r   r>   r   r   r;   rl  r  r   r   r  r   rD  rE  rF  rG  r  s   &    @r   test_send_buffer_timeout%ChannelTests.test_send_buffer_timeout  s   
	.&& *.D& \\566""7+C"":..%%c3%L / 7
 \\-((""7+C""<00%%c3s%K 1""9#>#>??&s+d8n% @	 ) \\+,,""7+C  *AGGI!!#sT2!FFFH -,3  	K ##$IJJ	K /.. 766 100???	 )(( -,,sw   G7 7H01H	H047I,+I	/I,4 I	I,=A0J 7"HH-'	H00I	I	I,I)#	I,,I=	 J	c                  aa R pV P                  V4      oV P                  R4      ;_uu_ 4        \        P                  \        4      oVV3R lp\
        P                  ! VR7      pVP                  4        V P                  \        P                  4      ;_uu_ 4        \        P                  SVRR7       RRR4       VP                  4        RRR4       V P                  R4      ;_uu_ 4        \        P                  \        4      oVV3R lp\
        P                  ! VR7      pVP                  4        V P                  \        P                  4      ;_uu_ 4        \        P                  SVR^R	7       RRR4       VP                  4        RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     LP; i  + '       g   i     R# ; i)
r   without timeoutc                  D   < S! 4        \         P                  S R R7       R# Tr   Nr   rc   r   ru  s   r   r@  6ChannelTests.test_send_closed_while_waiting.<locals>.f      40r   rB  Tr   Nwith timeoutc                  D   < S! 4        \         P                  S R R7       R# r  r  r  s   r   r@  r    r  r   r  )rz  r"  r   r>   r   rD  rE  rF  r   rR   ra   rG  rB   r   r@  rH  r   ru  s   &   @@r   test_send_closed_while_waiting+ChannelTests.test_send_closed_while_waiting  sA   %%c*\\+,,""7+C1   *AGGI""9#?#?@@sC$7 AFFH - \\.))""7+C1   *AGGI""9#?#?@@sC$C AFFH *)	 A@ -,$ A@ *))sI   A/F.F	7F.0A/GG	9GF+&F..F>	GGG%	c                \  aa  V P                    R V n         \	        R4      pT P                  TR R7      oT P                  R4      ;_uu_ 4        \        P                  \        4      oTT3R lp\        P                  ! TR7      pTP                  4        T P                  \        P                  4      ;_uu_ 4        \        P                  STR R7       RRR4       TP!                  4        RRR4       T P                  R	4      ;_uu_ 4        \        P                  \        4      oTT3R
 lp\        P                  ! TR7      pTP                  4        T P                  \        P                  4      ;_uu_ 4        \        P                  STR ^R7       RRR4       TP!                  4        RRR4       R#   \         d    \        P                  ! R4      hi ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     Lw; i  + '       g   i     R# ; i)Tr  r   r  r  c                  D   < S! 4        \         P                  S R R7       R# r  r  r  s   r   r@  =ChannelTests.test_send_buffer_closed_while_waiting.<locals>.f  r  r   rB  r   Nr  c                  D   < S! 4        \         P                  S R R7       R# r  r  r  s   r   r@  r    r  r   r  )_has_run_once_closedr  r  r  rk  rz  r"  r   r>   r   rD  rE  rF  r   rR   rl  rG  r  s   &   @@r   %test_send_buffer_closed_while_waiting2ChannelTests.test_send_buffer_closed_while_waiting  s   
	-%% )-D% %%c$%7\\+,,""7+C1   *AGGI""9#?#?@@%%c3%> AFFH - \\.))""7+C1   *AGGI""9#?#?@@%%c3r%J AFFH *)1  	K ##$IJJ	K( A@@ -,,$ A@ *))sU   F: A/G3=G	G3A/H>H	H:"GG0*	G33H	HHH+	c                   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  V4       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir   Fr   rN  N	r   r>   r   ra   r   rc   r   rR   r   r   s   & r   test_close_single_user#ChannelTests.test_close_single_user  s    w'sGe4Cy;;<<NN3( =y;;<<NN3 =< =<<<<   9C?C2C/	2D	c                n   \         P                  \        4      p\        P                  ! 4       p\        P                  ! 4       p\        P                  ! V\        R V R24      4       \        P                  ! V\        RV R24      4       \         P                  V4       \        P                  ! V\        RV R24      4      pV P                  VP                  P                  R4       \        P                  ! V\        RV R24      4      pV P                  VP                  P                  R4       R# )r  r;  r  r  z 
                _channels.send(z, b'spam')
                rR   N)
r   r>   r   r	   r*   r   rc   r   r}   rG   )rB   r   r   r   excsnaps   &    r   test_close_multiple_users&ChannelTests.test_close_multiple_users  s(   w'""$""$  f 25 !. ' 	 	  f 25 !. ' 	 	**3 <  #u %8 1  	..0DE**3 <  #u %8 1  	..0DEr   c                Z   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  V4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     R# ; ir2  )r   r>   r   ra   r   rc   r   rR   r   s   & r   test_close_multiple_times&ChannelTests.test_close_multiple_times  sj    w'sGe4Cy;;<<OOC  =<<<s   9BB*	c           
        . ROpV EF  w  r#V P                  W#34      ;_uu_ 4        \        P                  \        4      p\        P	                  VRR R7       \        V4       \        P                  WBVR7       V P                  \        P                  4      ;_uu_ 4        \        P	                  VR4       RRR4       V P                  \        P                  4      ;_uu_ 4        \        P                  V4       RRR4       RRR4       EK
  	  R#   + '       g   i     Ld; i  + '       g   i     L2; i  + '       g   i     EKF  ; i)Fr   r   r   rN  N))FFTF)FT)TT)
r"  r   r>   r   ra   r   rc   r   rR   r   )rB   testsra   r   r   s   &    r   test_close_emptyChannelTests.test_close_empty#  s      JDtl++&&w/sGe<C T:&&y'C'CDDNN30 E&&y'C'CDDNN3' E ,+   EDDD ,++s<   A;D;"D9/D;(D(>D;D% D;(D83D;;Ec                   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       V P	                  \         P
                  4      ;_uu_ 4        \         P                  V4       RRR4       \        V4       \         P                  VRRR7       R#   + '       g   i     L5; i)r   Fr      hamNrN  r   r>   r   ra   r   ChannelNotEmptyErrorrc   r   r   s   & r   %test_close_defaults_with_unused_items2ChannelTests.test_close_defaults_with_unused_items6  s    w'sGe4sFU3y==>>OOC  ?CsGe4 ?>s   1B44C	c                   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       V P	                  \         P
                  4      ;_uu_ 4        \         P                  VRR7       RRR4       \        V4       \         P                  VRRR7       \        V4       \        V4       \         P                  VRR7       R#   + '       g   i     Lb; i)r   Fr   r  Tr   NrN  r  r   s   & r   *test_close_recv_with_unused_items_unforced7ChannelTests.test_close_recv_with_unused_items_unforced@  s    w'sGe4sFU3y==>>OOCdO+ ?CsGe4CC$' ?>s   1C##C3	c                V   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       \         P	                  VRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       \        V4       \        V4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     Lm; i  + '       g   i     R# ; i)r   Fr   r  Tr   rN  N)	r   r>   r   ra   rc   r   rR   r   r   r   s   & r   *test_close_send_with_unused_items_unforced7ChannelTests.test_close_send_with_unused_items_unforcedM  s    w'sGe4sFU3$'y;;<<NN3( =CCy;;<<NN3 =<	 =< =<<s   D$DD	D(	c                   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       V P	                  \         P
                  4      ;_uu_ 4        \         P                  VRRR7       RRR4       \        V4       \         P                  VRRR7       \        V4       \        V4       \         P                  VRR7       R#   + '       g   i     Lb; i)	r   Fr   r  Tr   NrN  r  r  r   s   & r   *test_close_both_with_unused_items_unforced7ChannelTests.test_close_both_with_unused_items_unforcedZ  s    w'sGe4sFU3y==>>OOCdO6 ?CsGe4CC$' ?>s   1C$$C4	c                ,   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       \         P	                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)r   Fr   r  Tr   rN  Nr   r>   r   ra   rc   r   rR   r   r   s   & r   (test_close_recv_with_unused_items_forced5ChannelTests.test_close_recv_with_unused_items_forcedg      w'sGe4sFU3$d3y;;<<NN3( =y;;<<NN3 =< =<<<<   	C/D/C?	D	c                ,   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       \         P	                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)r   Fr   r  Tr   rN  Nr  r   s   & r   (test_close_send_with_unused_items_forced5ChannelTests.test_close_send_with_unused_items_forcedr  r  r  c                .   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       \         P	                  VRRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)r   Fr   r  Tr   rN  Nr  r   s   & r   (test_close_both_with_unused_items_forced5ChannelTests.test_close_both_with_unused_items_forced}  s    w'sGe4sFU3$T>y;;<<NN3( =y;;<<NN3 =< =<<<<s   
C0D0D 	D	c                   \         P                  \        4      p\         P                  V4       V P	                  \         P
                  4      ;_uu_ 4        \         P                  VR 4       RRR4       V P	                  \         P
                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir   N)r   r>   r   rc   r   rR   ra   r   r   s   & r   test_close_never_used"ChannelTests.test_close_never_used  s    w'y;;<<NN3( =y;;<<NN3 =< =<<<<   B<C<C	C 	c                <   \         P                  \        4      p\         P                  VR RR7       \        P                  ! 4       p\        P
                  ! V\        RV R24      4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)r   Fr   r  r  N)r   r>   r   ra   r	   r*   r   r   rR   r   rc   rB   r   r:   s   &  r   !test_close_by_unassociated_interp.ChannelTests.test_close_by_unassociated_interp  s    w'sGe4%%'   5 E "1 * 	 y;;<<NN3 =y;;<<OOC  =< =<<<<s   C7D
7D	
D	c                p   \         P                  \        4      p\         P                  VR RR7       \         P                  VR RR7       \         P                  VR RR7       \	        V4       \         P                  VRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)r   Fr   Tr   rN  Nr  r   s   & r   -test_close_used_multiple_times_by_single_user:ChannelTests.test_close_used_multiple_times_by_single_user  s    w'sGe4sGe4sGe4C4(y;;<<NN3( =y;;<<NN3 =< =<<<<s   +D1D$D!	$D5	c                   \         P                  \        4      pV P                  \         P                  4      ;_uu_ 4        \         P                  R RR7       RRR4       \         P                  V4       V P                  \         P                  4      ;_uu_ 4        \         P                  VRR7       RRR4       R#   + '       g   i     Ln; i  + '       g   i     R# ; i)r   Tr   N)r   r>   r   r   r   r   rc   rR   r   s   & r   .test_channel_list_interpreters_invalid_channel;ChannelTests.test_channel_list_interpreters_invalid_channel  s    w'y==>>''4'8 ? 	y;;<<''$'7 =< ?>
 =<<s   B?C?C	C#	c                    \         P                  \        4      pV P                  \        4      ;_uu_ 4        \         P                  V4       R R R 4       R #   + '       g   i     R # ; ir   )r   r>   r   r   r   r   r   s   & r   +test_channel_list_interpreters_invalid_args8ChannelTests.test_channel_list_interpreters_invalid_args  s@    w'y))'', *)))s   AA(	)r  r  N)9rG   rH   rI   rJ   r   r   r   r   r  r  r  r  r  r  r$  r+  r  skipr/  r5  r8  r<  rI  rO  rR  rU  rX  rb  rf  ro  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  rL   rM   r   s   @r   r   r   p  s'    8	D.&+2,@4+.)2V9,!9F4&.$ ]]=>. ?.&$
	'''8( 
%*D#$u .( ( ((2#J4$R	 F0!(&5( (	 	 	  ! 	8- -r   r   c                   d   a  ] tR tRt o Rt  R tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )ChannelReleaseTestsi  a}  
- main / interp / other
- run in: current thread / new thread / other thread / different threads
- end / opposite
- force / no force
- used / not used  (associated / not associated)
- empty / emptied / never emptied / partly emptied
- closed / not closed
- released / not released
- creator (interp) / other
- associated interpreter not running
- associated interpreter destroyed
c                   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir   Fr   Tr   rN  N	r   r>   r   ra   r   r  r   rR   r   r   s   & r   test_single_user$ChannelReleaseTests.test_single_user  s    w'sGe4C#Dt4y;;<<NN3( =y;;<<NN3 =< =<<<<s   <C"C5"C2	5D	c           
        \         P                  \        4      p\        P                  ! 4       p\        P                  ! 4       p\        P                  ! V\        R V R24      4       \        V\        RV RV R24      4      p\        P                  ! V\        RV R24      4       V P                  VP                  4       R4       R# )	r  r;  zU
            import _interpchannels as _channels
            obj, _ = _channels.recv(z )
            _channels.release(z+)
            print(repr(obj))
            z
            _channels.release(r  zb'spam'N)	r   r>   r   r	   r*   r   r
   r   r   )rB   r   r   r   r   s   &    r   test_multiple_users'ChannelReleaseTests.test_multiple_users  s    w'""$""$  f 25 !. ' 	 #v +%%(E *"e $'    	  f 2"e $. ' 	 	i0r   c                   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  V4       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir  r
  r   s   & r   test_no_kwargs"ChannelReleaseTests.test_no_kwargs  s    w'sGe4C#y;;<<NN3( =y;;<<NN3 =< =<<<<r  c                f   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VRRR7       RRR4       R#   + '       g   i     R# ; i)r   Fr   Tr   N)r   r>   r   ra   r   r  r   rR   r   s   & r   test_multiple_times'ChannelReleaseTests.test_multiple_times  s|    w'sGe4C#Dt4y;;<<c48 =<<<s   <BB0	c                z   \         P                  \        4      p\         P                  VR RR7       \         P                  VRRR7       \         P	                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     R# ; i)r   Fr   r  Tr   N)r   r>   r   ra   r  r   rR   r   r   s   & r   test_with_unused_items*ChannelReleaseTests.test_with_unused_items  s}    w'sGe4sFU3#Dt4y;;<<NN3 =<<<s   	B))B:	c                   \         P                  \        4      p\         P                  V4       V P	                  \         P
                  4      ;_uu_ 4        \         P                  VR 4       RRR4       V P	                  \         P
                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir  )r   r>   r   r  r   rR   ra   r   r   s   & r   test_never_used#ChannelReleaseTests.test_never_used$  s    w'#y;;<<NN3( =y;;<<NN3 =< =<<<<r  c                   \         P                  \        4      p\         P                  VR RR7       \        P                  ! 4       p\        P
                  ! V\        RV R24      4       \        V4      p\         P                  V4       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  VR 4       R#   + '       g   i     L$; i)r   Fr   r  r  rN  N)r   r>   r   ra   r	   r*   r   r   r  r   rR   r   )rB   r   r:   r   s   &   r   test_by_unassociated_interp/ChannelReleaseTests.test_by_unassociated_interp-  s    w'sGe4%%'   5"e $1 * 	 ##y;;<<NN3( =g& =<s   2C%%C5	c           
     b   \         P                  \        4      p\        P                  ! 4       p\        P                  ! V\        R V RV R24      4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     R# ; i)zR
            import _interpchannels as _channels
            obj = _channels.send(z9, b'spam', blocking=False)
            _channels.release(r  N)	r   r>   r   r	   r*   r   r   rR   r   r  s   &  r   test_close_if_unassociated.ChannelReleaseTests.test_close_if_unassociated<  s    w'%%'   5""% '"e $1 * 	 y;;<<NN3 =<<<s   =BB.	c                   \         P                  \        4      p\         P                  VR RR7       \	        V4       \         P                  VRRR7       \         P                  VRR7       \	        V4      pV P                  VR4       R # )NFr   r   Tr   )r   r>   r   ra   r   r  r   )rB   r   r   s   &  r   test_partially"ChannelReleaseTests.test_partiallyI  sk    w'sD51CsGe4#D)#g&r   c                r   \         P                  \        4      p\         P                  VR RR7       \         P                  VR RR7       \         P                  VR RR7       \	        V4       \         P                  VRRR7       V P                  \         P                  4      ;_uu_ 4        \         P                  VR4       RRR4       V P                  \         P                  4      ;_uu_ 4        \         P                  V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; ir	  r
  r   s   & r   'test_used_multiple_times_by_single_user;ChannelReleaseTests.test_used_multiple_times_by_single_userT  s    w'sGe4sGe4sGe4C#Dt4y;;<<NN3( =y;;<<NN3 =< =<<<<s   ,D2D%D"	%D6	rE   N)rG   rH   rI   rJ   __doc__r  r  r  r  r  r  r  r   r#  r&  rL   rM   r   s   @r   r  r    sK     "	 1(	 9  ' 	'   r   r  c                      a a ] tR tRt oRtV 3R lt]R 4       t]R 4       tR t	RR lt
R tR	 tR
 tR tR tR tRtVtV ;t# )ChannelCloseFixtureib  Fc                  < VR9   g   Q hV P                   '       d   / pMe\        P                  V4      p\        P                  V4      p\        P                  V4      pVP                  VVP                  VVP                  V/pV'       g   Rp\        SV `  WW#WE4      p\        4       Vn        \        4       Vn	        Wgn
        V# )ra   r_   r   )QUICKr0   r7   rA   r?   r@   r   _preppedrs   _state_known)	r5   rZ   r:   re   rf   creatorknownrB   rC   s	   &&&&&&  r   r@   ChannelCloseFixture.__new__i  s    &&&&999E ))&1F((/E((/EV

E

EE
 GwsG"nr   c                    V P                   # r   r.  r~   s   &r   r   ChannelCloseFixture.state~  s    {{r   c                     V P                   #   \         dA    T P                  T P                  4      pT P	                  T4      T n         T P                   u # i ; ir   )_cidr  _get_interpreterr0  _new_channel)rB   r0  s   & r   r   ChannelCloseFixture.cid  sP    	99 	++DLL9G))'2DI99	s    AAAc                J    V P                  V4      pV P                  V4       V# r   )r8  _prep_interpreterrB   r:   s   &&r   get_interpreter#ChannelCloseFixture.get_interpreter  s%    &&v.v&r   c                    Vf   V P                   pVR8X  d   V P                  P                  R8X  d   R# \        V P                  P                  4      # )Nr   ra   F)rZ   r   rt   boolrl   s   &&r   expect_closed_error'ChannelCloseFixture.expect_closed_error  s@    ;((C&=TZZ..&8DJJ%%&&r   c                (    V P                  V4       R # r   )r<  r=  s   &&r   prep_interpreter$ChannelCloseFixture.prep_interpreter  s    v&r   c                    W n         R # r   r4  )rB   rY   r   s   &&&r   record_action!ChannelCloseFixture.record_action  s    r   c                .    \        4        \        4        R # r   )r   r   r~   s   &r   clean_upChannelCloseFixture.clean_up  s    r   c                    VP                   R 8X  d   \        P                  \        4      # \        P                  \        4      p\	        VP
                  RV R24       \        V4      V n        V P                  # )r,   z
                import _interpreters
                cid = _xxsubchannels.create()
                # We purposefully send back an int to avoid tying the
                # channel to the other interpreter.
                _xxsubchannels.send(zN, int(cid), blocking=False)
                del _interpreters
                )rA   r   r>   r   r$   r!   r   r7  )rB   r0  chs   && r   r9   ChannelCloseFixture._new_channel  sj    <<6!##G,,!!'*Bwzz (%
 &(D )$  $BDIyyr   c                    VR9   d   V P                   # VR8X  d   V P                  # VR8X  d   V P                  # Tp V P                  V,          pV#   \         d    \        T4      ;qP                  T&    T# i ; i)r_   re   rf   )r_   r:   )r:   re   rf   r/  KeyErrorr0   )rB   r:   rA   s   && r   r8  $ChannelCloseFixture._get_interpreter  s    '';;w::w::D?T* M  ?-8->>T*M?s   A $A:9A:c                    VP                   V P                  9   d   R # V P                  P                  VP                   4       VP                  R8X  d   R # \	        VP                   RV P
                   R24       R # )Nr,   a  
            import _interpchannels as channels
            import test.test__interpchannels as helpers
            ChannelState = helpers.ChannelState
            try:
                cid
            except NameError:
                cid = _channels._channel_id(r  )r!   r-  addrA   r$   r   r=  s   &&r   r<  %ChannelCloseFixture._prep_interpreter  sb    99%&))$;;& 699 #- .2XXJ 7 	r   )r7  r/  r-  r.  r   )rG   rH   rI   rJ   r,  r@   propertyr   r   r>  rB  rE  rH  rK  r9  r8  r<  rL   rM   rN   rO   s   @@r   r*  r*  b  sf     
 E*    
''  r   r*  zend interp other extra creatorz%these tests take several hours to runc                      a  ] tR tRt o Rt  R tR tR tR tR t	RR	/R
 lt
R tR tRR ltR tRR ltR tR tR tRtV tR# )ExhaustiveChannelTestsi  a  
- main / interp / other
- run in: current thread / new thread / other thread / different threads
- end / opposite
- force / no force
- used / not used  (associated / not associated)
- empty / emptied / never emptied / partly emptied
- closed / not closed
- released / not released
- creator (interp) / other
- associated interpreter not running
- associated interpreter destroyed

- close after unbound
c              #    "   . x  V P                  R R4       F(  pVx  V P                  4        F  pW,           x  K  	  K*  	  V P                  RR4       F(  pVx  V P                  4        F  pW,           x  K  	  K*  	  V P                  R R4       F  pVx  V P                  R R4       F0  pW1,           pVx  V P                  4        F  pWB,           x  K  	  K2  	  V P                  RR4       F0  pW1,           pVx  V P                  4        F  pWB,           x  K  	  K2  	  K  	  V P                  RR4       F  pVx  V P                  R R4       F0  pW1,           pVx  V P                  4        F  pWB,           x  K  	  K2  	  V P                  RR4       F0  pW1,           pVx  V P                  4        F  pWB,           x  K  	  K2  	  K  	  R# 5i)r_   re   rf   N)_iter_close_action_sets_iter_post_close_action_sets_iter_use_action_sets)rB   closeactionspostactions
useactionsactionss   &    r   iter_action_sets'ExhaustiveChannelTests.iter_action_sets  s      !88IL#@@B"00  C J !88'JL#@@B"00  C K 44VWEJ $ < <VW M$3#'#D#D#FK!// $G !N
 !% < <Wg N$3#'#D#D#FK!// $G !O F 44WgFJ $ < <VW M$3#'#D#D#FK!// $G !N
 !% < <Wg N$3#'#D#D#FK!// $G !O Gs   GGc              #  :  "   W3p\        R RV4      .x  \        R RV4      .x  \        R RV4      \        R RV4      .x  \        R RV4      .x  \        R RV4      .x  \        R RV4      \        R RV4      .x  V F=  pV F4  pV F+  p\        R RV4      \        R RV4      \        R RV4      .x  K-  	  K6  	  K?  	  V FR  pV FI  pV F@  pV F7  p\        R RV4      \        R RV4      \        R RV4      \        R RV4      .x  K9  	  KB  	  KK  	  KT  	  R# 5i)r]   r   ra   NrU   )rB   r  r	  interpsr
  interp4s   &&&   r   r\  ,ExhaustiveChannelTests._iter_use_action_sets+  sg    $ %1 	 %1 	 %1%1 	 %1 	 %1 	 %1%1 	 G"&G%eVW=%eVW=%eVW=   ' #  G"&G#*)%A)%A)%A)%A	  $+  ' # s   DDc           
   #    "   RpW3pR F0  pV'       d   RMRpV F  pV F  p\        WhV4      .x  K  	  K  	  K2  	  R F:  p	R F1  p
V F(  pV F  p\        V	R V4      \        V
RV4      .x  K!  	  K*  	  K3  	  K<  	  R# 5i)r   ra   rd   rc   Nr   r  rb   rd  )rB   r  r	  endsre  r   opr:   rZ   recvopsendopr   ra   s   &&&          r   rZ  .ExhaustiveChannelTests._iter_close_action_sets\  s     $"E"'WB!C%bv6    " # /F2#D ')&&$?)&&$?  !( $ 3 /s   A>B c              #  `   "   R F#  p\        RRV4      .x  \        RRV4      .x  K%  	  R# 5i)r_   r]   r   ra   N)r_   rf   re   rd  r=  s   & r   r[  3ExhaustiveChannelTests._iter_post_close_action_setso  s=     0FeVV4  eVV4 	 1s   ,.c                :    V F  pV P                  W4       K  	  R # r   )r   )rB   fixr`  rY   s   &&& r   run_actions"ExhaustiveChannelTests.run_actionsx  s    FOOC( r   r   Tc                  VP                  VP                  4      pVP                  VP                  VP                  VP
                  4      pVP                  V4       VP                  R 8X  dB   \        VP                  VP                  VVP                  VR7      pVP                  W&4       R
# \        P                  \        4      p\!        VP"                  RVP                   R\%        VP                  4       R\%        V4       R\%        VP                  4       RV RV RV R24       \'        \(        P+                  \-        V4      R4      \/        \-        V4      4      R	7      pVP                  W&4       R
# )r,   r   zB
                result = helpers.run_action(
                    z,
                    z!,
                    hideclosed=z7,
                    )
                _channels.send(zW, result.pending.to_bytes(1, 'little'), blocking=False)
                _channels.send(zB, b'X' if result.closed else b'', blocking=False)
                little)rv   rt   N)rm   rZ   rp   r:   re   rf   rE  rA   r   r   rY   r   rH  r   r>   r   r$   r!   r   rs   r=   
from_bytesr   rA  )rB   rq  rY   r   rZ   r:   r   r7  s   &&&$    r   r   !ExhaustiveChannelTests.run_action|  sJ     )&&szz399ciiHV$;;& 		%F f-##G,Dvyy 'WWI &--() *#YK  #))_% &  *| ,  $v &  $v &
# 
 "{4'8(CK-.F f-r   c           
   #  p   "   . ROpV F'  w  r#pR F  pR F  p\        WbW4V4      x  K  	  K  	  K)  	  R# 5i)r,   N))r,   r:   rf   )r:   r,   rf   )r  r	  rf   )r  r	  r,   )r_   re   r0  r   )r*  )rB   interpretersr:   re   rf   r0  rZ   s   &      r   iter_fixtures$ExhaustiveChannelTests.iter_fixtures  s@     
 %1 F57+C-c5QQ , 8 %1s   46c               N   V'       d   R MRp\        W1P                  R4      pVP                  4       '       g   V P                  WRR7       R# V P	                  \
        P                  4      ;_uu_ 4        V P                  WRR7       RRR4       R#   + '       g   i     R# ; i)rd   rc   r_   Fru  N)rU   rZ   rB  r   r   r   rR   )rB   rq  r   rj  rc   s   &&$  r   _closeExhaustiveChannelTests._close  sq    #]b''62&&((OOC5O9""9#?#?@@u= A@@@s   5BB$	Nc                   Ve   VP                   R8X  EdB   V P                  \        P                  4      ;_uu_ 4        \        P	                  VP
                  4       R R R 4       V P                  \        P                  4      ;_uu_ 4        \        P                  VP
                  R4       R R R 4       V P                  \        P                  4      ;_uu_ 4        \        P                  VP
                  4       R R R 4       V P                  \        P                  4      ;_uu_ 4        \        P                  VP
                  RR7       R R R 4       R # \        VP                  R4       \        VP                  R4       \        VP                  R4       \        VP                  R4       R #   + '       g   i     EL]; i  + '       g   i     EL!; i  + '       g   i     L; i  + '       g   i     R # ; i)	Nr,   r   Tr   zo
                with helpers.expect_channel_closed():
                    _channels.recv(cid)
                z
                with helpers.expect_channel_closed():
                    _channels.send(cid, b'spam', blocking=False)
                zp
                with helpers.expect_channel_closed():
                    _channels.close(cid)
                z|
                with helpers.expect_channel_closed():
                    _channels.close(cid, force=True)
                )
rA   r   r   rR   r   r   ra   rc   r$   r!   )rB   rq  r:   s   &&&r   _assert_closed_in_interp/ExhaustiveChannelTests._assert_closed_in_interp  sK   >V[[F2""9#?#?@@sww' A""9#?#?@@sww0 A""9#?#?@@( A""9#?#?@@t4 A@ vyy #  vyy #  vyy #  vyy # + A@@@@@@@@@@s/    F2!G G,"G-2G	G	G*	-G>	c                   V P                  VP                  P                  4       \        VP                  P                  4       F  p\        VP                  4       K  	  V P                  V4       R F8  pVP                  V4      pVP                  R8X  d   K'  V P                  W4       K:  	  VP                  R4      pV P                  W4       R# )r_   r,   freshN)r_   re   )
r   r   rt   rangerv   r   r   r  r>  rA   )rB   rq  r-   r:   s   &&  r   _assert_closed%ExhaustiveChannelTests._assert_closed  s    		(()syy(()A  *%%c*'F((0F{{f$))#6	 ( $$W-%%c2r   c              #  &  "   ^ pV P                  4        F  p\        4        V P                  4        F  pV^,          pVR8  d     R# V'       dE   V^,
          ^,          ^ 8X  d   \        4        \        W$RP                  \	        V4      4      4       MMV^,
          ^,          ^ 8X  d   \        RRR7       \        RRR7       \
        P                  P                  4        W$V3x  K  	  V'       g   K  \        R4       K  	  \        4        R# 5i)	r   r   Nz({} actions)  rk   .z---)ra  r  r{  r<   r  sysstdoutflush)rB   verboseir`  rq  s   &&   r   _iter_close_tests(ExhaustiveChannelTests._iter_close_tests  s     ,,.GG))+Qt8A{a'!."7"7G"EFA{a'cr*#2&

(8(8(:go% , we! /" 	s   ADB D6Dc                P    R \         n        V P                  4        F  w  rpK  	  R# )TN)r*  r,  r  rB   r  rq  r`  s   &   r   _skim_close_tests(ExhaustiveChannelTests._skim_close_tests  s%    $(!#557OAG  8r   c                   V P                  4        F  w  rpV P                  R P                  WV4      4      ;_uu_ 4        VP                  VP                  4       V P                  W#4       V P                  VRR7       V P                  V4       RRR4       VP                  4        K  	  R#   + '       g   i     L&; i)	{} {}  {}Fr   N	r  r"  r<   rE  r:   rr  r~  r  rK  r  s   &   r   
test_close!ExhaustiveChannelTests.test_close  s    #557OAGk00ABB$$SZZ0  .Cu-##C( C LLN  8BB    AB//B?c                   V P                  4        F  w  rpV P                  R P                  WV4      4      ;_uu_ 4        VP                  VP                  4       V P                  W#4       V P                  VRR7       V P                  V4       RRR4       VP                  4        K  	  R#   + '       g   i     L&; i)r  Tr   Nr  r  s   &   r   test_force_close'ExhaustiveChannelTests.test_force_close  s    #557OAGk00ABB$$SZZ0  .Ct,##C( C LLN  8BBr  rE   r   )F)rG   rH   rI   rJ   r(  ra  r\  rZ  r[  rr  r   r{  r~  r  r  r  r  r  r  rL   rM   r   s   @r   rX  rX    sj       +0Z/b&).D .@R>83 ,


 
r   rX  __main__)-collectionsr   
contextlibr  textwrapr   rD  r   r  test.supportr   r   import_moduler   concurrent.interpretersr   test.test__interpretersr	   r
   r   _UNBOUND_CONSTANT_TO_FLAGUNBOUNDr   r   r   r$   r    r0   contextmanagerrS   rU   rs   r   r   r   TestCaser   r   r   r  r*  r  rX  rG   r,   rE   r   r   <module>r     s   "  
     9''(9:	 0  
0
01E1E
FE  $ -/ 
5 *]I6  J + +/#J0CD /#fE:n.>? E&d *!!H x    `,X `,J 8FI-8 I- GI-Xb ( b Jn*%:%EG nb 
67{X { 8{|	 zMMO r   