[Twisted-Python] Is that behavior of t.i.stdio.StandardIO known?
twisted-web at udmvt.ru
Thu Jul 29 03:23:48 EDT 2010
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.
o: dataReceived: 'blabla
o: readConnectionLost(input is done)
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.
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
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1515 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20100729/4f3d90d0/attachment.py
More information about the Twisted-Python