/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__/win32eventreactor.cpython-310.pyc (13881B)
o b;@sJdZddlZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZzddl mZWneyJddlZejded d d ZYnwddlZdd lmZmZmZmZmZdd lmZddlmZmZddl m!Z!ddl"m#Z#m$Z$m%Z%eeeGdddej&Z'GdddZ(eeGdddZ)ddZ*ddgZ+dS)a A win32event based implementation of the Twisted main loop. This requires pywin32 (formerly win32all) or ActivePython to be installed. To install the event loop (and you should do this before any connections, listeners or connectors are added):: from twisted.internet import win32eventreactor win32eventreactor.install() LIMITATIONS: 1. WaitForMultipleObjects and thus the event loop can only handle 64 objects. 2. Process running has some problems (see L{twisted.internet.process} docstring). TODO: 1. Event loop handling of writes is *very* problematic (this is causing failed tests). Switch to doing it the correct way, whatever that means (see below). 2. Replace icky socket loopback waker with event based waker (use dummyEvent object) 3. Switch everyone to using Free Software so we don't have to deal with proprietary APIs. ALTERNATIVE SOLUTIONS: - IIRC, sockets can only be registered once. So we switch to a structure like the poll() reactor, thus allowing us to deal with write events in a decent fashion. This should allow us to pass tests, but we're still limited to 64 events. Or: - Instead of doing a reactor, we make this an addon to the select reactor. The WFMO event loop runs in a separate thread. This means no need to maintain separate code for networking, 64 event limit doesn't apply to sockets, we can run processes and other win32 stuff in default event loop. The only problem is that we're stuck with the icky socket based waker. Another benefit is that this could be extended to support >64 events in a simpler manner than the previous solution. The 2nd solution is probably what will get implemented. N)Thread)WeakKeyDictionary) implementer) FD_ACCEPTFD_CLOSE FD_CONNECTFD_READWSAEventSelect)WSAEnumNetworkEventszAReliable disconnection notification requires pywin32 215 or later)categorycCsthSN)r)fdeventrD/usr/lib/python3/dist-packages/twisted/internet/win32eventreactor.pyr Lsr ) QS_ALLINPUT WAIT_OBJECT_0 WAIT_TIMEOUT CreateEventMsgWaitForMultipleObjects) posixbase) IReactorFDSetIReactorWin32Events)blockingCallFromThread)failurelog threadablec@seZdZdZeddddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZddZddZeZdS) Win32Reactora Reactor that uses Win32 event APIs. @ivar _reads: A dictionary mapping L{FileDescriptor} instances to a win32 event object used to check for read events for that descriptor. @ivar _writes: A dictionary mapping L{FileDescriptor} instances to a arbitrary value. Keys in this dictionary will be given a chance to write out their data. @ivar _events: A dictionary mapping win32 event object to tuples of L{FileDescriptor} instances and event masks. @ivar _closedAndReading: Along with C{_closedAndNotReading}, keeps track of descriptors which have had close notification delivered from the OS but which we have not finished reading data from. MsgWaitForMultipleObjects will only deliver close notification to us once, so we remember it in these two dictionaries until we're ready to act on it. The OS has delivered close notification for each descriptor in this dictionary, and the descriptors are marked as allowed to handle read events in the reactor, so they can be processed. When a descriptor is marked as not allowed to handle read events in the reactor (ie, it is passed to L{IReactorFDSet.removeReader}), it is moved out of this dictionary and into C{_closedAndNotReading}. The descriptors are keys in this dictionary. The values are arbitrary. @type _closedAndReading: C{dict} @ivar _closedAndNotReading: These descriptors have had close notification delivered from the OS, but are not marked as allowed to handle read events in the reactor. They are saved here to record their closed state, but not processed at all. When one of these descriptors is passed to L{IReactorFDSet.addReader}, it is moved out of this dictionary and into C{_closedAndReading}. The descriptors are keys in this dictionary. The values are arbitrary. This is a weak key dictionary so that if an application tells the reactor to stop reading from a descriptor and then forgets about that descriptor itself, the reactor will also forget about it. @type _closedAndNotReading: C{WeakKeyDictionary} NrcCs0i|_i|_i|_i|_t|_tj|dSr ) _reads_writes_events_closedAndReadingr_closedAndNotReadingrPosixReactorBase__init__selfrrrr$s zWin32Reactor.__init__cCs,tdddd}t|||||f|j|<|S)z9 Make a win32 event object for a socket. Nr)rr r )r&r actionwhyrrrr_makeSocketEvents zWin32Reactor._makeSocketEventcCs||f|j|<dS)z: Add a new win32 event to the event loop. Nr r&rr r'rrraddEventszWin32Reactor.addEventcCs |j|=dS)z" Remove an event. Nr*r&rrrr removeEvents zWin32Reactor.removeEventcCsR||jvr%||dttBtBtB|j|<||jvr'd|j|<|j|=dSdSdS)zY Add a socket FileDescriptor for notification of data available to read. doReadTN)rr)rrrrr"r!r&readerrrr addReaders    zWin32Reactor.addReadercCs||jvr d|j|<dSdS)zZ Add a socket FileDescriptor for notification of data available to write. Nrr&writerrrr addWriters zWin32Reactor.addWritercCsH||jvr |j|j|=|j|=||jvr"d|j|<|j|=dSdSdS)z?Remove a Selectable for notification of data available to read.TN)rr r!r"r0rrr removeReaders    zWin32Reactor.removeReadercCs||jvr |j|=dSdS)z@Remove a Selectable for notification of data available to write.Nr4r5rrr removeWriters  zWin32Reactor.removeWritercCs||j|jS)zD Remove all selectables, and return a list of them. ) _removeAllrrr%rrr removeAllszWin32Reactor.removeAllcCt|jSr )listrkeysr%rrr getReaderszWin32Reactor.getReaderscCr<r )r=rr>r%rrr getWritersr@zWin32Reactor.getWritersc Cstjdd|d|durd}d}t|jD] }d}|d|qt|jD] }d}t||j|q)|r:d}|j sG|jsGt |dSt|j pQ|j g}t |d }t|d|t}|tkredS|tt|kr~t}|r||d|jdSdS|tkr|tt|kr||t}|j |\}} ||jvr|} | d kr||tjddSt| |} t| vrd|j|<t||j| |dSdSdS) Nsystem iteration)channelrreactordFTr/ri)rmsgr=r!r> _runActionrcallWithLogger _runWriter timesleep dummyEventintrrrrlenwin32guiPumpWaitingMessages callLaterstoprfileno_disconnectSelectabler _NO_FILEDESCr r) r&timeout ranUserCoder1r handlesvalexitrr'rUeventsrrrdoWaitForMultipleEventssN       z$Win32Reactor.doWaitForMultipleEventscCsd}z|}Wntytd}tYnw|rB||||z |t |WdStyAtYdSw|durHdSdS)Nrr3) doWrite BaseExceptionsysexc_infordeferrr8r9connectionLostrFailure)r&r closedrrrrKs$       zWin32Reactor._runWritecCsVzt||}Wntytd}tYnw|r)||||dkdSdS)Nr3r/)getattrr`rarbrrcrV)r&r'r rfrrrrI-s   zWin32Reactor._runAction)__name__ __module__ __qualname____doc__rrNr$r)r,r.r2r7r8r9r;r?rAr^rKrI doIterationrrrrr`s$(  @ rc@s0eZdZdZddZddZddZdd Zd S) _ThreadFDWrappera7 This wraps an event handler and translates notification in the helper L{Win32Reactor} thread into a notification in the primary reactor thread. @ivar _reactor: The primary reactor, the one to which event notification will be sent. @ivar _fd: The L{FileDescriptor} to which the event will be dispatched. @ivar _action: A C{str} giving the method of C{_fd} which handles the event. @ivar _logPrefix: The pre-fetched log prefix string for C{_fd}, so that C{_fd.logPrefix} does not need to be called in a non-main thread. cCs||_||_||_||_dSr )_reactor_fd_action _logPrefix)r&rEr r' logPrefixrrrr$Is z_ThreadFDWrapper.__init__cCs|jS)zc Return the original handler's log prefix, as it was given to C{__init__}. )rqr%rrrrrOsz_ThreadFDWrapper.logPrefixcstjfddS)a- Callback fired when the associated event is set. Run the C{action} callback on the wrapped descriptor in the main reactor thread and raise or return whatever it raises or returns to cause this event handler to be removed from C{self._reactor} if appropriate. cstjjSr )rgrorprr%rr^sz+_ThreadFDWrapper._execute..)rrnr%rr%r_executeVsz_ThreadFDWrapper._executecCs|j|jj|dS)z Pass through to the wrapped descriptor, but in the main reactor thread instead of the helper C{Win32Reactor} thread. N)rncallFromThreadrord)r&reasonrrrrdasz_ThreadFDWrapper.connectionLostN)rhrirjrkr$rrrtrdrrrrrm9s  rmc@s8eZdZdZdZdZddZddZddZd d Z dS) _ThreadedWin32EventsMixina This mixin implements L{IReactorWin32Events} for another reactor by running a L{Win32Reactor} in a separate thread and dispatching work to it. @ivar _reactor: The L{Win32Reactor} running in the other thread. This is L{None} until it is actually needed. @ivar _reactorThread: The L{threading.Thread} which is running the L{Win32Reactor}. This is L{None} until it is actually needed. NcCs|j|jjd|_dS)zP Stop and discard the reactor started by C{_makeHelperReactor}. N)rnrurTr%rrr_unmakeHelperReactorys z._ThreadedWin32EventsMixin._unmakeHelperReactorcCs@t|_d|j_t|jjdd|_|dd|j|jdS)z Create and (in a new thread) start a L{Win32Reactor} instance to use for the implementation of L{IReactorWin32Events}. F)F)targetargsaftershutdownN) rrn_registerAsIOThreadrrun_reactorThreadaddSystemEventTriggerrxstartr%rrr_makeHelperReactors z,_ThreadedWin32EventsMixin._makeHelperReactorc Cs:|jdur ||j|jj|t||||ddS). @see: L{IReactorWin32Events} Nrt)rnrrur,rmrrr+rrrr,s z"_ThreadedWin32EventsMixin.addEventcCs|j|jj|dS)rN)rnrur.r-rrrr.sz%_ThreadedWin32EventsMixin.removeEvent) rhrirjrkrnrrxrr,r.rrrrrwis  rwcCs*tdt}ddlm}||dS)Nr3)main)rinitrrinstallReactor)rrrrrinstalls  r),rkrarL threadingrweakrefrzope.interfacer win32filerrrrr r ImportErrorwarningswarn UserWarningrQ win32eventrrrrrtwisted.internetrtwisted.internet.interfacesrrtwisted.internet.threadsrtwisted.pythonrrrr#rrmrwr__all__rrrrs>*        Y07