/usr/lib/python3/dist-packages/twisted/internet/__pycache__
NameSizeModeActions
abstract.cpython-310.pyc176100644editdlrm
address.cpython-310.pyc56700644editdlrm
asyncioreactor.cpython-310.pyc99550644editdlrm
base.cpython-310.pyc408700644editdlrm
cfreactor.cpython-310.pyc156380644editdlrm
default.cpython-310.pyc11720644editdlrm
defer.cpython-310.pyc687400644editdlrm
endpoints.cpython-310.pyc733480644editdlrm
epollreactor.cpython-310.pyc69210644editdlrm
error.cpython-310.pyc150360644editdlrm
fdesc.cpython-310.pyc31730644editdlrm
gireactor.cpython-310.pyc40980644editdlrm
glib2reactor.cpython-310.pyc14680644editdlrm
gtk2reactor.cpython-310.pyc25890644editdlrm
gtk3reactor.cpython-310.pyc18690644editdlrm
inotify.cpython-310.pyc108480644editdlrm
interfaces.cpython-310.pyc1173770644editdlrm
kqreactor.cpython-310.pyc85820644editdlrm
main.cpython-310.pyc9750644editdlrm
pollreactor.cpython-310.pyc59600644editdlrm
posixbase.cpython-310.pyc234570644editdlrm
process.cpython-310.pyc286110644editdlrm
protocol.cpython-310.pyc306580644editdlrm
pyuisupport.cpython-310.pyc9730644editdlrm
reactor.cpython-310.pyc19200644editdlrm
selectreactor.cpython-310.pyc53030644editdlrm
serialport.cpython-310.pyc27780644editdlrm
ssl.cpython-310.pyc89290644editdlrm
stdio.cpython-310.pyc9840644editdlrm
task.cpython-310.pyc321410644editdlrm
tcp.cpython-310.pyc466840644editdlrm
testing.cpython-310.pyc333470644editdlrm
threads.cpython-310.pyc42080644editdlrm
tksupport.cpython-310.pyc21690644editdlrm
udp.cpython-310.pyc165840644editdlrm
unix.cpython-310.pyc195310644editdlrm
utils.cpython-310.pyc93270644editdlrm
win32eventreactor.cpython-310.pyc138810644editdlrm
wxreactor.cpython-310.pyc48970644editdlrm
wxsupport.cpython-310.pyc16930644editdlrm
_baseprocess.cpython-310.pyc22160644editdlrm
_dumbwin32proc.cpython-310.pyc116270644editdlrm
_glibbase.cpython-310.pyc117910644editdlrm
_idna.cpython-310.pyc14940644editdlrm
_newtls.cpython-310.pyc87140644editdlrm
_pollingfile.cpython-310.pyc84760644editdlrm
_posixserialport.cpython-310.pyc21910644editdlrm
_posixstdio.cpython-310.pyc53090644editdlrm
_producer_helpers.cpython-310.pyc38670644editdlrm
_resolver.cpython-310.pyc84020644editdlrm
_signals.cpython-310.pyc28240644editdlrm
_sslverify.cpython-310.pyc684120644editdlrm
_threadedselect.cpython-310.pyc117550644editdlrm
_win32serialport.cpython-310.pyc37070644editdlrm
_win32stdio.cpython-310.pyc40240644editdlrm
__init__.cpython-310.pyc6080644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/internet/__pycache__/asyncioreactor.cpython-310.pyc (9955B)
o ¯b{+ã@s®dZddlZddlZddlmZmZddlmZmZm Z ddl m Z ddl m Z ddlmZddlmZmZmZdd lmZdd lmZe eƒGd d „d eƒƒZdd d„ZdS)z' asyncio-based reactor implementation. éN)ÚAbstractEventLoopÚget_event_loop)ÚDictÚOptionalÚType)Ú implementer)ÚFileDescriptor)Ú IReactorFDSet)Ú _NO_FILEDESCÚPosixReactorBaseÚ_ContinuousPolling)ÚLogger)ÚcallWithLoggercsÐeZdZdZdZeƒZd,deef‡fdd„ Z dd„Z d d „Z d d „Z d d„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd-dd„Z‡fdd„Z‡fd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Z‡ZS).ÚAsyncioSelectorReactora† Reactor running on top of L{asyncio.SelectorEventLoop}. On POSIX platforms, the default event loop is L{asyncio.SelectorEventLoop}. On Windows, the default event loop on Python 3.7 and older is C{asyncio.WindowsSelectorEventLoop}, but on Python 3.8 and newer the default event loop is C{asyncio.WindowsProactorEventLoop} which is incompatible with L{AsyncioSelectorReactor}. Applications that use L{AsyncioSelectorReactor} on Windows with Python 3.8+ must call C{asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())} before instantiating and running L{AsyncioSelectorReactor}. FNÚ eventloopcsx|durtƒ}n|}tjdkr!ddlm}t||ƒr!td|›ƒ‚||_i|_i|_ t |ƒ|_ d|_ d|_ tƒ ¡dS)NÚwin32r)ÚProactorEventLoopz)ProactorEventLoop is not supported, got: )rÚsysÚplatformÚasynciorÚ isinstanceÚ TypeErrorÚ_asyncioEventloopÚ_writersÚ_readersr Ú_continuousPollingÚ _scheduledAtÚ _timerHandleÚsuperÚ__init__)ÚselfrÚ _eventloopr©Ú __class__©úA/usr/lib/python3/dist-packages/twisted/internet/asyncioreactor.pyr0s    ÿ zAsyncioSelectorReactor.__init__cCs*z |jj |¡WdStyYdSw)am Compensate for a bug in asyncio where it will not unregister a FD that it cannot handle in the epoll loop. It touches internal asyncio code. A description of the bug by markrwilliams: The C{add_writer} method of asyncio event loops isn't atomic because all the Selector classes in the selector module internally record a file object before passing it to the platform's selector implementation. If the platform's selector decides the file object isn't acceptable, the resulting exception doesn't cause the Selector to un-track the file object. The failing/hanging stdio test goes through the following sequence of events (roughly): * The first C{connection.write(intToByte(value))} call hits the asyncio reactor's C{addWriter} method. * C{addWriter} calls the asyncio loop's C{add_writer} method, which happens to live on C{_BaseSelectorEventLoop}. * The asyncio loop's C{add_writer} method checks if the file object has been registered before via the selector's C{get_key} method. * It hasn't, so the KeyError block runs and calls the selector's register method * Code examples that follow use EpollSelector, but the code flow holds true for any other selector implementation. The selector's register method first calls through to the next register method in the MRO * That next method is always C{_BaseSelectorImpl.register} which creates a C{SelectorKey} instance for the file object, stores it under the file object's file descriptor, and then returns it. * Control returns to the concrete selector implementation, which asks the operating system to track the file descriptor using the right API. * The operating system refuses! An exception is raised that, in this case, the asyncio reactor handles by creating a C{_ContinuousPolling} object to watch the file descriptor. * The second C{connection.write(intToByte(value))} call hits the asyncio reactor's C{addWriter} method, which hits the C{add_writer} method. But the loop's selector's get_key method now returns a C{SelectorKey}! Now the asyncio reactor's C{addWriter} method thinks the asyncio loop will watch the file descriptor, even though it won't. N)rÚ _selectorÚ unregisterÚ BaseException)r Úfdr$r$r%Ú_unregisterFDInAsyncioKs 2 ÿz-AsyncioSelectorReactor._unregisterFDInAsyncioc Csˆ|r|jn|j}| ¡dkr| |t|¡dSz|ƒ}Wnty6}z|}|j d¡WYd}~nd}~ww|rB| |||¡dSdS©Néÿÿÿÿ)ÚdoReadÚdoWriteÚfilenoÚ_disconnectSelectabler Ú ExceptionÚ_logÚfailure)r Ú selectableÚreadÚmethodÚwhyÚer$r$r%Ú _readOrWrite‚s  €þÿz#AsyncioSelectorReactor._readOrWritec Csœ||j ¡vs ||jjvrdS| ¡}z|j |t||j|d¡||j|<WdStyM}z|  |¡|j t j krA|j  |¡n‚WYd}~dSd}~ww)NT) rÚkeysrr/rÚ add_readerrr9ÚOSErrorr*ÚerrnoÚEPERMÚ addReader)r Úreaderr)r8r$r$r%r?‘s ÿ  þ€úz AsyncioSelectorReactor.addReadercCs®||j ¡vs ||jjvrdS| ¡}z|j |t||j|d¡||j|<WdSty<|  |¡|j  |¡YdSt yJ|  |¡YdSt yV|  |¡‚w)NF) rr:rr/rÚ add_writerrr9ÚPermissionErrorr*Ú addWriterÚBrokenPipeErrorr(©r Úwriterr)r$r$r%rC¥s"ÿ     þz AsyncioSelectorReactor.addWritercCót||j ¡vs|j |¡sdS|j |¡r|j |¡dS| ¡}|dkr,|j |¡}n|j |¡|j |¡dSr+) rr:rÚ isReadingÚ removeReaderr/ÚpoprÚ remove_reader)r r@r)r$r$r%rI¼s   z#AsyncioSelectorReactor.removeReadercCrGr+) rr:rÚ isWritingÚ removeWriterr/rJrÚ remove_writerrEr$r$r%rMÔs   z#AsyncioSelectorReactor.removeWritercCs"| |j ¡|j ¡¡|j ¡S©N)Ú _removeAllrr:rrÚ removeAll©r r$r$r%rQísÿÿz AsyncioSelectorReactor.removeAllcCót|j ¡ƒ|j ¡SrO)Úlistrr:rÚ getReadersrRr$r$r%rUóóz!AsyncioSelectorReactor.getReaderscCrSrO)rTrr:rÚ getWritersrRr$r$r%rWörVz!AsyncioSelectorReactor.getWriterscCs$|j |d|jj¡|j ¡dS)Ng{®Gáz„?)rÚ call_laterÚstopÚ run_forever)r Útimeoutr$r$r%ÚiterateùszAsyncioSelectorReactor.iterateTcCs*|j|d|j ¡|jrd|_dSdS)N)ÚinstallSignalHandlersF)Ú startRunningrrZÚ _justStopped)r r]r$r$r%Úrunýs   ÿzAsyncioSelectorReactor.runcstƒ ¡| ddd„¡dS)NrcSsdSrOr$r$r$r$r%Úsz-AsyncioSelectorReactor.stop..)rrYÚ callLaterrRr"r$r%rYs zAsyncioSelectorReactor.stopcstƒ ¡|j ¡dSrO)rÚcrashrrYrRr"r$r%rc s zAsyncioSelectorReactor.crashcCsd|_| ¡| ¡dSrO)rÚrunUntilCurrentÚ _reschedulerRr$r$r%Ú_onTimer s zAsyncioSelectorReactor._onTimercCsR| ¡}|dur'|j ¡|}||_|jdur|j ¡|j ||j¡|_dSdSrO)r[rÚtimerrÚcancelÚcall_atrf)r r[Úabs_timer$r$r%res  ûz"AsyncioSelectorReactor._reschedulecCst ||¡| ¡dSrO)r Ú_moveCallLaterSoonerre)r Útpler$r$r%rks  z+AsyncioSelectorReactor._moveCallLaterSoonercOsNtj|||g|¢Ri|¤Ž}|j ¡| ¡}|jdus!||jkr%| ¡|SrO)r rbrrgr[rre)r ÚsecondsÚfÚargsÚkwargsÚdcrjr$r$r%rbs z AsyncioSelectorReactor.callLatercs"‡‡‡‡fdd„}ˆj |¡dS)Ncsˆjdˆgˆ¢Riˆ¤ŽS)Nr)rbr$©rornrpr r$r%ra'sz7AsyncioSelectorReactor.callFromThread..)rÚcall_soon_threadsafe)r rnrorpÚgr$rrr%ÚcallFromThread&sz%AsyncioSelectorReactor.callFromThreadrO)T)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú _asyncClosedr r2rrrr*r9r?rCrIrMrQrUrWr\r`rYrcrfrerkrbruÚ __classcell__r$r$r"r%rs.7    rcCs t|ƒ}ddlm}||ƒdS)z‘ Install an asyncio-based reactor. @param eventloop: The asyncio eventloop to wrap. If default, the global one is selected. r)ÚinstallReactorN)rÚtwisted.internet.mainr|)rÚreactorr|r$r$r%Úinstall+s  rrO)ryr=rrrrÚtypingrrrÚzope.interfacerÚtwisted.internet.abstractrÚtwisted.internet.interfacesr Útwisted.internet.posixbaser r r Útwisted.loggerr Útwisted.python.logrrrr$r$r$r%Ús