%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/win32eventreactor.cpython-312.pyc |
� Ϫ�fa; � � � d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z mZmZm Z mZ ddl mZ ddlZddlmZmZmZmZmZ ddlmZ dd lmZmZ ddl m!Z! ddl"m#Z#m$Z$m%Z% eee� G d� dejL � � Z' G d� d� Z( ee� G d� d� � Z)d� Z*ddgZ+y# e$ r ddlZ ej$ de� � d � ZY ��w xY w)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_ACCEPT�FD_CLOSE� FD_CONNECT�FD_READ�WSAEventSelect)�WSAEnumNetworkEventszAReliable disconnection notification requires pywin32 215 or later)�categoryc � � t hS �N)r )�fd�events �D/usr/lib/python3/dist-packages/twisted/internet/win32eventreactor.pyr r F s � ��y�� )�QS_ALLINPUT� WAIT_OBJECT_0�WAIT_TIMEOUT�CreateEvent�MsgWaitForMultipleObjects)� posixbase)� IReactorFDSet�IReactorWin32Events)�blockingCallFromThread)�failure�log� threadablec �~ � e Zd ZdZ edddd� Zd� Zd� Zd� Zd� Z d� Z d � Zd � Zd� Z d� Zd � Zd� Zd� Zd� Zd� ZeZy)�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} Nr c � � i | _ i | _ i | _ i | _ t � | _ t j j | � y r ) �_reads�_writes�_events�_closedAndReadingr �_closedAndNotReadingr �PosixReactorBase�__init__��selfs r r( zWin32Reactor.__init__� s>