[Twisted-Python] Is that behavior of t.i.stdio.StandardIO known?
The code is in attachment. I run it on Debian/Linux, twisted 10.0.0 When you run it on a terminal, it works by prefixing the data you enter with "dataReceived: " and outputting that back to terminal. $ ./program.py i: blabla o: dataReceived: 'blabla o: ' i: ^D o: readConnectionLost(input is done) i: ^C o: OK $ The same happens if you redirect output to a pipe (no matter if it a named FIFO or an anonymous pipe). But if you redirect output to a file or to a /dev/null, this happens: $ ./program.py > /dev/null <a short pause, no input> o: StdioProtocol.connectionLost('[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion. o: ]')OK $ But I expected it to work the same way, regardless of redirections. I haven't traced the source of that Failure, so just asking, whether that behavior is known, or maybe intended? Or, perhaps, I do something incorrectly? Well, right now I'm using the workaround with /bin/cat: $ ./program.py > >(cat > file) or with an extra shell process: $ ./program.py | cat > file
On Thu, 2010-07-29 at 11:23 +0400, Alexey wrote:
The same happens if you redirect output to a pipe (no matter if it a named FIFO or an anonymous pipe). But if you redirect output to a file or to a /dev/null, this happens: $ ./program.py > /dev/null <a short pause, no input> o: StdioProtocol.connectionLost('[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion. o: ]')OK $
This was a bug, and was fixed in Twisted 10.1. From the release notes: """ - twisted.internet.stdio now supports stdout being redirected to a normal file (except when using epollreactor). (#2259) """ So, upgrade to Twisted 10.1.
On Thu, Jul 29, 2010 at 08:13:06AM -0400, Itamar Turner-Trauring wrote:
This was a bug, and was fixed in Twisted 10.1. From the release notes:
""" - twisted.internet.stdio now supports stdout being redirected to a normal file (except when using epollreactor). (#2259) """
So, upgrade to Twisted 10.1.
Great!!! Thanks a lot! -- Alexey.
participants (2)
-
Alexey
-
Itamar Turner-Trauring