K i lddlmZddlZddlZddlZddlZddlmZmZm Z m Z ddl m Z m Z ddlmZddlmZddlmZddlmZmZmZGd d eZGd d eZGd deZGddeZGddZGddeZGddeZGddeZ e!dk(rejDyy))futuresN)Future chain_futurerun_on_executor"future_set_result_unless_cancelled)utf8 to_unicode)gen)IOStream) TCPServer) AsyncTestCasebind_unused_portgen_testceZdZdZy)MiscFutureTestct}t|d|j|jd|j |j t}|j |j }t|d|j|j ||s!|j|jdyyN*)rr assertEqualresult assertFalse cancelledcancel)selffut is_cancelleds b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/test/concurrent_test.py'test_future_set_result_unless_cancelledz6MiscFutureTest.test_future_set_result_unless_cancelled#sh*33 r* )h }} *33 ,7   SZZ\2 .N)__name__ __module__ __qualname__rrrrr"s /rrc,eZdZedZedZy)ChainFutureTestcKt}t}t|||jd|d{}|j|dy7wr)rr set_resultr)rrfut2rs rtest_asyncio_futuresz$ChainFutureTest.test_asyncio_futures3sF!8"HS$ r $s7AAAcKtj}tj}t}t||t|||jd|d{}|j |dy7wr)rrrr'r)rrr(fut3rs rtest_concurrent_futuresz'ChainFutureTest.test_concurrent_futures<sc $+>>#3$+NN$4"HS$T4  r $sA!A=#A;$A=N)r r!r"rr)r,r#rrr%r%2s( %% % %rr%c0eZdZejdZy) CapServerc#K|jd}t|}||jk(r|jdn+|jt d|jz|j yw)N serror already capitalized zok %s) read_untilr upperwriterclose)rstreamaddressdatas r handle_streamzCapServer.handle_streamPse&&u--$ 4::<  LL8 9 LLh56 7 sBBN)r r!r"r coroutiner8r#rrr.r.Os]]rr.c eZdZy)CapErrorN)r r!r"r#rrr;r;\srr;ceZdZdZdZy) BaseCapClientc||_yNport)rrAs r__init__zBaseCapClient.__init__as  rctjdt|}| td|j \}}|dk(r|St |)Nz (.*) (.*) z did not matchok)rematchr Exceptiongroupsr;)rr7mstatusmessages rprocess_responsezBaseCapClient.process_responsedsM HH^Z%5 6 9O, ,((* T>N7# #rN)r r!r"rBrLr#rrr=r=`s $rr=c0eZdZejdZy)GeneratorCapClientc#Ktjdttj}tjd|j d|j f|j t|dztjd|jd}tjd|jtj|j|w)N capitalize connectingz 127.0.0.1 readingr0 returning) loggingdebugr socketconnectrAr3rr1r4r ReturnrL)r request_datar5r7s rrPzGeneratorCapClient.capitalizeps l#&--/* l#nnk499566 T,-./ i &&u-- k" jj..t455sC5C7N)r r!r"r r9rPr#rrrNrNos]] 6 6rrNc@eZdZfdZfdZdZdZdZdZxZ S)GeneratorCapClientTestct|t|_t \}}|jj |gt ||_y)Nr@)supersetUpr.serverr add_socketsrNclient)rsockrA __class__s rr_zGeneratorCapClientTest.setUpsA  k %' d '(d3 rcV|jjt| yr?)r`stopr^tearDown)rrds rrgzGeneratorCapClientTest.tearDowns  rc|jjd}|jj||j|j |j |jdyNhelloHELLO)rbrPio_loop add_futurerfwaitrrrfutures r test_futurez"GeneratorCapClientTest.test_futuresM''0  2  '2rc|jjd}|jj||j|j |j td|jy)Nrkalready capitalized) rbrPrlrmrfrnassertRaisesRegexr;rros rtest_future_errorz(GeneratorCapClientTest.test_future_errorsN''0  2  x)> Nrcltjfd}jj|y)Nc3lKjjd}j|dywri)rbrPr)rrs rfz0GeneratorCapClientTest.test_generator..fs.;;11'::F   VW -s14r r9rlrun_syncrrxs` rtest_generatorz%GeneratorCapClientTest.test_generators-  .  . a rcltjfd}jj|y)Nc3Kjtd5jjddddy#1swYyxYww)Nrsrk)rtr;rbrPrsrrxz6GeneratorCapClientTest.test_generator_error..fsA''2GH 6kk,,W55 6 6 6sA A A A A ryr{s` rtest_generator_errorz+GeneratorCapClientTest.test_generator_errors-  6  6 a r) r r!r"r_rgrqrur|r __classcell__)rds@rr\r\~s"43 O !!rr\cLeZdZedZedZedZedZy)RunOnExecutorTestc#vKGdd}|}|j}|j|dyw)Nc"eZdZdZedZy)1RunOnExecutorTest.test_no_calling..ObjectcLtjjd|_yNrthreadThreadPoolExecutorexecutorrs rrBz:RunOnExecutorTest.test_no_calling..Object.__init__ ' A A! D rcyrr#rs rrxz3RunOnExecutorTest.test_no_calling..Object.frNr r!r"rBrrxr#rrObjectrs E  rrrrxrrroanswers rtest_no_callingz!RunOnExecutorTest.test_no_calling6   Hssu $79c#vKGdd}|}|j}|j|dyw)Nc,eZdZdZedZy)8RunOnExecutorTest.test_call_with_no_args..ObjectcLtjjd|_yrrrs rrBzARunOnExecutorTest.test_call_with_no_args..Object.__init__rrcyrr#rs rrxz:RunOnExecutorTest.test_call_with_no_args..Object.frrNrr#rrrr E   rrrrrs rtest_call_with_no_argsz(RunOnExecutorTest.test_call_with_no_argsrrc#vKGdd}|}|j}|j|dyw)Nc0eZdZdZeddZy)9RunOnExecutorTest.test_call_with_executor..ObjectcLtjjd|_yr)rrr_Object__executorrs rrBzBRunOnExecutorTest.test_call_with_executor..Object.__init__s").."C"CA"Frr)rcyrr#rs rrxz;RunOnExecutorTest.test_call_with_executor..Object.frrNrr#rrrrs" G&9 : ; rrrrrs rtest_call_with_executorz)RunOnExecutorTest.test_call_with_executorrrc#pKGdd}|fd}|}|j|dyw)Nc,eZdZdZedZy)2RunOnExecutorTest.test_async_await..ObjectcLtjjd|_yrrrs rrBz;RunOnExecutorTest.test_async_await..Object.__init__rrcyrr#rs rrxz4RunOnExecutorTest.test_async_await..Object.frrNrr#rrrrrrrcDKjd{}|S7wr?)rx)rrs rrxz-RunOnExecutorTest.test_async_await..fs335[FM!s   r)r)rrrxrrs @rtest_async_awaitz"RunOnExecutorTest.test_async_awaits:   H s $s36N)r r!r"rrrrrr#rrrrsP  % % % % % %%%rr__main__)# concurrentrrUrErWunittesttornado.concurrentrrrrtornado.escaperr tornador tornado.iostreamr tornado.tcpserverr tornado.testingr rrrr%r.rGr;r=rNr\rr mainr#rrrs  ,%'EE /] / %m%:   y  $ $ 6 6&!]&!R<% <%~ zHMMOr