+
    üÐjÉ&  ã                   ót  € R t ^ RIt^ RIt^ RIHtHtHtHtHtH	t	H
t
HtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^RIHt RtRt ]P$                  P3                  R	4      '       d   ^ R
IHtHt RtRt]! 4       P;                  4       t]! ]]4      t ]PC                  4         ! R R]]4      t"R#   ] d     LEi ; i)z/
Tests for L{twisted.internet.asyncioreactor}.
N)	ÚAbstractEventLoopÚAbstractEventLoopPolicyÚDefaultEventLoopPolicyÚFutureÚSelectorEventLoopÚget_event_loopÚget_event_loop_policyÚset_event_loopÚset_event_loop_policy)ÚskipIf)ÚAsyncioSelectorReactor)Úplatform)ÚSynchronousTestCase)ÚReactorBuilderFÚwin32)ÚWindowsProactorEventLoopPolicyÚWindowsSelectorEventLoopPolicyTc            
       ó<  a € ] tR t^0t o RtR tV 3R lR lt]! ]'       * RP                  ]
! ]4      ]P                  P                  ]P                  P                  ]P"                  ! 4       4      4      R 4       t]! ]'       * RP                  ]
! ]4      ]P                  P                  ]P                  P                  ]P"                  ! 4       4      4      R 4       t]! ]RP                  ]
! ]4      ]P                  P                  ]P                  P                  ]P"                  ! 4       4      4      R	 4       t]! ]'       * R
4      R 4       t]! ]'       * R4      R 4       t]! ]'       * R4      R 4       t]! ]'       * R4      R 4       tR tR tR tR tRtV t R# )ÚAsyncioSelectorReactorTestsz"
L{AsyncioSelectorReactor} tests.
c                óä   aa€ \        4       p. oVV3R lpVP                  V4       VP                  R4       V P                  S. 4       V P	                  S^R7       V P                  SR.4       R# )zV
Ensure that C{reactor} has an event loop that works
properly with L{asyncio.Future}.
c                 óf   <€ SP                  V P                  4       4       SP                  4        R # ©N)ÚappendÚresultÚstop)ÚfutureÚreactorr   s   &€€ÚK/usr/lib/python3/dist-packages/twisted/internet/test/test_asyncioreactor.pyÚ	completedÚRAsyncioSelectorReactorTests.assertReactorWorksWithAsyncioFuture.<locals>.completed=   s   ø€ Ø�M‰M˜&Ÿ-™-›/Ô*Ø�L‰LŽNó    T)ÚtimeoutN)r   Úadd_done_callbackÚ
set_resultÚassertEqualÚ
runReactor)Úselfr   r   r   r   s   &f  @r   Ú#assertReactorWorksWithAsyncioFutureÚ?AsyncioSelectorReactorTests.assertReactorWorksWithAsyncioFuture5   sf   ù€ ô
 “ˆØˆö	ð 	× Ñ  Ô+Ø×Ñ˜$Ôà×Ñ˜ Ô$Ø�‰˜¨ˆÔ+Ø×Ñ˜ $ Ö(r    c                ó&   <€ V ^8„  d   QhRS[ RS[/# )é   ÚpolicyÚreturn)r   r   )ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú(AsyncioSelectorReactorTests.__annotate__H   s   ø€ ÷ ñ Ñ5ð Ñ:Kñ r    c                ó‚   aaa€ \        4       o\        4       oVP                  4       oV P                  VVV3R l4       pS# )zx
Make a new asyncio loop from a policy for use with a reactor, and add
appropriate cleanup to restore any global state.
c                  óT   <€ SP                  4        \        S 4       \        S4       R # r   )Úcloser	   r
   )ÚexistingLoopÚexistingPolicyr   s   €€€r   ÚcleanUpÚ4AsyncioSelectorReactorTests.newLoop.<locals>.cleanUpQ   s   ø€ à�L‰LŒNÜ˜<Ô(Ü! .Ö1r    )r   r   Únew_event_loopÚ
addCleanup)r&   r+   r6   r4   r5   r   s   && @@@r   ÚnewLoopÚ#AsyncioSelectorReactorTests.newLoopH   s@   ú€ ô
 &Ó'ˆÜ.Ó0ˆØ×&Ñ&Ó(ˆà	�‰ö	2ó 
ð	2ð
 ˆr    zLdefault event loop: {}
is not of type SelectorEventLoop on Python {}.{} ({})c                ó<   € \        4       pV P                  V4       R# )zÙ
L{AsyncioSelectorReactor} wraps the global policy's event loop
by default.  This ensures that L{asyncio.Future}s and
coroutines created by library code that uses
L{asyncio.get_event_loop} are bound to the same loop.
N)r   r'   ©r&   r   s   & r   Ú-test_defaultSelectorEventLoopFromGlobalPolicyÚIAsyncioSelectorReactorTests.test_defaultSelectorEventLoopFromGlobalPolicyY   s   € ô" )Ó*ˆØ×0Ñ0°Ö9r    c                ó†   € V P                  \        4       4      p\        V4      p\        V4       V P	                  V4       R# )zÄ
If we use the L{asyncio.DefaultLoopPolicy} to create a new event loop,
and then pass that event loop to a new L{AsyncioSelectorReactor},
this reactor should work properly with L{asyncio.Future}.
N)r:   r   r   r	   r'   ©r&   Ú
event_loopr   s   &  r   Ú3test_newSelectorEventLoopFromDefaultEventLoopPolicyÚOAsyncioSelectorReactorTests.test_newSelectorEventLoopFromDefaultEventLoopPolicym   s6   € ð  —\‘\Ô"8Ó":Ó;ˆ
Ü(¨Ó4ˆÜ�zÔ"Ø×0Ñ0°Ö9r    zHdefault event loop: {}
is of type SelectorEventLoop on Python {}.{} ({})c                ó:   € V P                  \        \        4       R# )a9  
On Windows Python 3.5 to 3.7, L{get_event_loop()} returns a
L{WindowsSelectorEventLoop} by default.
On Windows Python 3.8+, L{get_event_loop()} returns a
L{WindowsProactorEventLoop} by default.
L{AsyncioSelectorReactor} should raise a
L{TypeError} if the default event loop is not a
L{WindowsSelectorEventLoop}.
N)ÚassertRaisesÚ	TypeErrorr   ©r&   s   &r   Ú1test_defaultNotASelectorEventLoopFromGlobalPolicyÚMAsyncioSelectorReactorTests.test_defaultNotASelectorEventLoopFromGlobalPolicy‚   s   € ð( 	×Ñœ)Ô%;Ö<r    z&WindowsProactorEventLoop not availablec                ón   € V P                  \        4       4      pV P                  \        \        V4       R# )zp
L{AsyncioSelectorReactor} will raise a L{TypeError}
if instantiated with a L{asyncio.WindowsProactorEventLoop}
N)r:   r   rF   rG   r   )r&   rB   s   & r   Útest_WindowsProactorEventLoopÚ9AsyncioSelectorReactorTests.test_WindowsProactorEventLoop˜   s)   € ð —\‘\Ô"@Ó"BÓCˆ
Ø×Ñœ)Ô%;¸ZÖHr    z(WindowsSelectorEventLoop only on Windowsc                ó†   € V P                  \        4       4      p\        V4      p\        V4       V P	                  V4       R# )zB
L{WindowsSelectorEventLoop} works with L{AsyncioSelectorReactor}
N)r:   r   r   r	   r'   rA   s   &  r   Útest_WindowsSelectorEventLoopÚ9AsyncioSelectorReactorTests.test_WindowsSelectorEventLoop£   s6   € ð —\‘\Ô"@Ó"BÓCˆ
Ü(¨Ó4ˆÜ�zÔ"Ø×0Ñ0°Ö9r    z.WindowsProactorEventLoopPolicy only on Windowsc                óØ   € \        \        4       4       V P                  R 4       V P                  \        4      ;_uu_ 4        \        4        RRR4       R#   + '       g   i     R# ; i)zn
L{AsyncioSelectorReactor} will raise a L{TypeError}
if L{asyncio.WindowsProactorEventLoopPolicy} is default.
c                  ó   € \        R 4      # r   ©r
   © r    r   Ú<lambda>ÚQAsyncioSelectorReactorTests.test_WindowsProactorEventLoopPolicy.<locals>.<lambda>º   ó
   € Ô 5°dÔ ;r    N)r
   r   r9   rF   rG   r   rH   s   &r   Ú#test_WindowsProactorEventLoopPolicyÚ?AsyncioSelectorReactorTests.test_WindowsProactorEventLoopPolicy°   sC   € ô 	Ô<Ó>Ô?Ø�‰Ñ;Ô<Ø×Ñœy×)Õ)Ü"Ô$÷ *×)×)Ò)ús   ÁAÁA)	z.WindowsSelectorEventLoopPolicy only on Windowsc                ó†   € \        \        4       4       V P                  R 4       \        4       pV P	                  V4       R# )za
L{AsyncioSelectorReactor} will work if
if L{asyncio.WindowsSelectorEventLoopPolicy} is default.
c                  ó   € \        R 4      # r   rS   rT   r    r   rU   ÚQAsyncioSelectorReactorTests.test_WindowsSelectorEventLoopPolicy.<locals>.<lambda>È   rW   r    N)r
   r   r9   r   r'   r=   s   & r   Ú#test_WindowsSelectorEventLoopPolicyÚ?AsyncioSelectorReactorTests.test_WindowsSelectorEventLoopPolicy¾   s3   € ô 	Ô<Ó>Ô?Ø�‰Ñ;Ô<Ü(Ó*ˆØ×0Ñ0°Ö9r    c                óä   € \         '       d&   \        \        4       4       V P                  R 4       \	        4       pVP                  4       pV P                  VR4       V P                  VR4       R# )z0L{seconds} should return a plausible epoch time.c                  ó   € \        R 4      # r   rS   rT   r    r   rU   Ú:AsyncioSelectorReactorTests.test_seconds.<locals>.<lambda>Ð   ó
   € Ô$9¸$Ô$?r    i á^l    #G4 N)Ú!hasWindowsSelectorEventLoopPolicyr
   r   r9   r   ÚsecondsÚassertGreaterÚ
assertLess)r&   r   r   s   &  r   Útest_secondsÚ(AsyncioSelectorReactorTests.test_secondsÌ   sW   € ç,Ó,Ü!Ô"@Ó"BÔCØ�O‰OÑ?Ô@Ü(Ó*ˆØ—‘Ó"ˆð 	×Ñ˜6 :Ô.ð 	�‰˜ 
Ö+r    c                óÂ  aa€ \         '       d&   \        \        4       4       V P                  R 4       \	        4       oR.oVV3R lpSP                  4       pSP                  ^ V4      pVP                  R4       SP                  ^SP                  4       SP                  4        V P                  S^ ,          4       V P                  S^ ,          V,
          R4       R# )zA
L{DelayedCall.reset()} properly reschedules timer to later time
c                  ó   € \        R 4      # r   rS   rT   r    r   rU   ÚJAsyncioSelectorReactorTests.test_delayedCallResetToLater.<locals>.<lambda>à   rb   r    Nc                  ó.   <€ S P                  4       S^ &   R# ©é    N©rd   ©r   Útimer_called_ats   €€r   Úon_timerÚJAsyncioSelectorReactorTests.test_delayedCallResetToLater.<locals>.on_timeræ   ó   ø€ Ø!(§¡Ó!2ˆO˜AÓr    ç      à?çš™™™™™Ù?)rc   r
   r   r9   r   rd   Ú	callLaterÚresetr   ÚrunÚassertIsNotNonere   )r&   rr   Ú
start_timeÚdcr   rq   s   &   @@r   Útest_delayedCallResetToLaterÚ8AsyncioSelectorReactorTests.test_delayedCallResetToLaterÚ   s­   ù€ ÷ -Ó,Ü!Ô"@Ó"BÔCØ�O‰OÑ?Ô@ä(Ó*ˆà˜&ˆö	3ð —_‘_Ó&ˆ
Ø×Ñ˜q (Ó+ˆØ
�‰�ŒØ×Ñ˜!˜WŸ\™\Ô*Ø�‰Œà×Ñ˜_¨QÕ/Ô0Ø×Ñ˜?¨1Õ-°
Õ:¸CÖ@r    c                óœ  aa€ \         '       d   \        \        4       4       \        4       oR.oVV3R lpSP	                  4       pSP                  RV4      pVP                  ^ 4       SP                  ^SP                  4       ^ RIp^ RI	H
p VP                  4       pV! V4      ;_uu_ 4        SP                  4        RRR4       V P                  VP                  4       R4       V P                  S^ ,          4       V P!                  S^ ,          V,
          R4       \         '       d   \        R4       R# R#   + '       g   i     Lƒ; i)zC
L{DelayedCall.reset()} properly reschedules timer to earlier time
Nc                  ó.   <€ S P                  4       S^ &   R# rm   ro   rp   s   €€r   rr   ÚLAsyncioSelectorReactorTests.test_delayedCallResetToEarlier.<locals>.on_timerü   rt   r    ru   )Úredirect_stderrÚ rv   )rc   r
   r   r   rd   rw   rx   r   ÚioÚ
contextlibr‚   ÚStringIOry   r$   Úgetvaluerz   rf   )	r&   rr   r{   r|   r„   r‚   Ústderrr   rq   s	   &      @@r   Útest_delayedCallResetToEarlierÚ:AsyncioSelectorReactorTests.test_delayedCallResetToEarlierò   sô   ù€ ÷ -Ó,Ü!Ô"@Ó"BÔCÜ(Ó*ˆà˜&ˆö	3ð —_‘_Ó&ˆ
Ø×Ñ˜s HÓ-ˆØ
�‰�ŒØ×Ñ˜!˜WŸ\™\Ô*ãÝ.à—‘“ˆÙ˜V×$Õ$Ø�K‰KŒM÷ %ð 	×Ñ˜Ÿ™Ó*¨BÔ/Ø×Ñ˜_¨QÕ/Ô0Ø�‰˜¨Õ*¨ZÕ7¸Ô=ß,Ó,Ü! $Ö'ñ -÷ %×$ús   Â/D;Ä;E	c                ó„  € \         '       d   \        \        4       4       \        P                  ! 4       p\        P
                  ! 4         \        \        P                  ! 4       4      pRp\        4       p\        V4       F  pVP                  ^ R 4       K  	  VP                  4        \        \        P                  ! 4       4      pV P                  Wb,
          V,          ^4       V'       d   \        P                  ! 4        \         '       d   \        R4       R# R#   T'       d   \        P                  ! 4        i i ; i)zG
L{AsyncioSelectorReactor.callLater()} doesn't leave cyclic references
iè  c                  ó   € R # r   rT   rT   r    r   rU   ÚOAsyncioSelectorReactorTests.test_noCycleReferencesInCallLater.<locals>.<lambda>  s   € ©Tr    N)rc   r
   r   ÚgcÚ	isenabledÚdisableÚlenÚget_objectsr   Úrangerw   ÚrunUntilCurrentrf   Úenable)r&   Úgc_was_enabledÚobjects_beforeÚtimer_countr   Ú_Úobjects_afters   &      r   Ú!test_noCycleReferencesInCallLaterÚ=AsyncioSelectorReactorTests.test_noCycleReferencesInCallLater  sÓ   € ÷ -Ó,Ü!Ô"@Ó"BÔCÜŸš›ˆÜ
�
Š
Œð	Ü ¤§¢Ó!1Ó2ˆNØˆKä,Ó.ˆGÜ˜;Ö'�Ø×!Ñ! !¡\Ö2ñ (à×#Ñ#Ô%ä¤§¢Ó 0Ó1ˆMØ�O‰O˜]Õ;¸{ÕJÈAÔNçÜ—	’	”ß,Ó,Ü! $Ö'ñ -ø÷ Ü—	’	•ð ús   ÁBD Ä D?rT   N)!Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r'   r:   r   Ú_defaultEventLoopIsSelectorr-   ÚtypeÚ_defaultEventLoopÚsysÚversion_infoÚmajorÚminorr   ÚgetTyper>   rC   rI   Ú!hasWindowsProactorEventLoopPolicyrL   rc   rO   rX   r]   rg   r}   r‰   r›   Ú__static_attributes__Ú__classdictcell__)r.   s   @r   r   r   0   sÝ  ø‡ € ñò)÷&ð ñ" Ø'Ô'ð	ß%™vÙÐ"Ó#Ø×Ñ×"Ñ"Ø×Ñ×"Ñ"Ø×ÒÓó	 
ó	ñ:ó	ð:ñ Ø'Ô'ð	ß%™vÙÐ"Ó#Ø×Ñ×"Ñ"Ø×Ñ×"Ñ"Ø×ÒÓó	 
ó	ñ	:ó	ð	:ñ Ø#ð	ß%™vÙÐ"Ó#Ø×Ñ×"Ñ"Ø×Ñ×"Ñ"Ø×ÒÓó	 
ó	ñ
=ó	ð
=ñ Ø-Ô-Ð/WóñIóðIñ Ø-Ô-Ø2óñ:ó	ð:ñ Ø-Ô-Ø8óñ%ó	ð%ñ Ø-Ô-Ø8óñ:ó	ð:ò,òAò0(÷>(ð (r    r   )#r¡   rŽ   r¥   Úasyncior   r   r   r   r   r   r   r	   r
   Úunittestr   Útwisted.internet.asyncioreactorr   Útwisted.python.runtimer   Útwisted.trial.unittestr   Úreactormixinsr   rª   rc   Ú
startswithr   r   ÚImportErrorr8   r¤   Ú
isinstancer¢   r3   r   rT   r    r   Ú<module>r¶      s¿   ðñó 
Û 
÷
÷ 
õ 
õ å BÝ +Ý 6Ý )à$)Ð !Ø$)Ð !ð
	Ø
‡|�|×Ñ˜w×'Ò'÷	
ð
 -1Ð)Ø,0Ð)ñ
 +Ó,×;Ñ;Ó=Ð Ù(Ð):Ð<MÓNÐ Ø × Ñ Ô ôx( .Ð2Eö x(øð ô 	Ùð	ús   Á B- Á%B- Â-B7Â6B7