[Twisted-Python] UDP crashes python.exe when using IOCPReactor
Josh Albrecht
thejash at gmail.com
Tue Dec 15 16:56:26 MST 2009
I've been struggling to move a large program over to IOCPReactor, but
it is causing python.exe to crash on windows. I reduced the error to
this program, which crashes almost immediately on all the machines
I've tested it on. Am I doing something wrong?
#############################################
from twisted.internet.iocpreactor.reactor import IOCPReactor
from twisted.internet.main import installReactor
from twisted.internet.protocol import DatagramProtocol
reactor = IOCPReactor()
installReactor(reactor)
DATA = 'HELLO'
REMOTE_IP = "127.0.0.1"
REMOTE_PORT = 33351
class EchoDatagram(DatagramProtocol):
def datagramReceived(self, datagram, addr):
print((addr, datagram))
self.transport.write(datagram, addr)
p1 = EchoDatagram()
listening_port1 = reactor.listenUDP(6951, p1, interface='')
p2 = EchoDatagram()
listening_port2 = reactor.listenUDP(REMOTE_PORT, p2, interface=REMOTE_IP)
def pointless_write():
p1.transport.write(DATA, (REMOTE_IP, REMOTE_PORT))
for i in xrange(10):
f = open("temp1", "wb")
f.write("Hi!")
f.close()
f = open("temp1", "rb")
data = f.read()
f.close()
reactor.callLater(1, pointless_write)
reactor.callLater(1, pointless_write)
reactor.run()
#############################################
This has been driving me crazy all day. Any insights would be greatly
appreciated!
Thanks,
Josh Albrecht
More information about the Twisted-Python
mailing list