source: trunk/misc/windows-enospc/passthrough.py

Last change on this file was a765d8a, checked in by Itamar Turner-Trauring <itamar@…>, at 2023-01-12T16:18:05Z

Unused.

  • Property mode set to 100644
File size: 996 bytes
Line 
1"""
2Writing to non-blocking pipe can result in ENOSPC when using Unix APIs on
3Windows.  So, this program passes through data from stdin to stdout, using
4Windows APIs instead of Unix-y APIs.
5"""
6
7from twisted.internet.stdio import StandardIO
8from twisted.internet import reactor
9from twisted.internet.protocol import Protocol
10from twisted.internet.interfaces import IHalfCloseableProtocol
11from twisted.internet.error import ReactorNotRunning
12from zope.interface import implementer
13
14@implementer(IHalfCloseableProtocol)
15class Passthrough(Protocol):
16    def readConnectionLost(self):
17        self.transport.loseConnection()
18
19    def writeConnectionLost(self):
20        try:
21            reactor.stop()
22        except ReactorNotRunning:
23            pass
24
25    def dataReceived(self, data):
26        self.transport.write(data)
27
28    def connectionLost(self, reason):
29        try:
30            reactor.stop()
31        except ReactorNotRunning:
32            pass
33
34
35std = StandardIO(Passthrough())
36reactor.run()
Note: See TracBrowser for help on using the repository browser.