A win32event based implementation of the twisted main loop.
To install the event loop (and you should do this before any connections,
listeners or connectors are added): from twisted.internet import win32
win32.install()
This requires win32all to be installed.
TODO:
1. Pass tests.
2. WaitForMultipleObjects can only handle 64 objects, so we need threads.
3. Event loop handling of writes is very problematic.
4. Support GUI events.
5. Replace icky socket loopback waker with event based waker.
6. Switch everyone to a decent OS so we don't have to deal with insane APIs.
Imported modules
|
|
import Queue
import msvcrt
import os
import pywintypes
import string
import threading
import time
from twisted.internet import abstract, main, task
from twisted.python import log, threadable
import win32api
import win32con
import win32event
from win32event import CreateEvent, WaitForMultipleObjects, WAIT_OBJECT_0, WAIT_TIMEOUT, INFINITE
import win32file
from win32file import WSAEventSelect, FD_READ, FD_WRITE, FD_CLOSE, FD_ACCEPT, FD_CONNECT
import win32pipe
import win32process
import win32security
|
Functions
|
|
|
|
_makeSocketEvent
|
_makeSocketEvent (
fd,
action,
why,
events=events,
)
Make a win32 event object for a socket.
|
|
addEvent
|
addEvent (
event,
fd,
action,
events=events,
)
Add a new win32 event to the event loop.
|
|
addReader
|
addReader ( reader, reads=reads )
Add a socket FileDescriptor for notification of data available to read.
|
|
addWriter
|
addWriter ( writer, writes=writes )
Add a socket FileDescriptor for notification of data available to write.
|
|
doWaitForMultipleEvents
|
doWaitForMultipleEvents (
timeout,
reads=reads,
writes=writes,
)
|
|
initThreads
|
initThreads ()
Do initialization for threads.
|
|
install
|
install ()
Install the win32 event loop.
|
|
removeAll
|
removeAll ()
Remove all selectables, and return a list of them.
|
|
removeEvent
|
removeEvent ( event )
Remove an event.
|
|
removeReader
|
removeReader ( reader )
Remove a Selectable for notification of data available to read.
|
|
removeWriter
|
removeWriter ( writer, writes=writes )
Remove a Selectable for notification of data available to write.
|
Classes
|
|
Process |
A process that integrates with the Twisted event loop.
|
|
|