[Twisted-Python] Is that behavior of t.i.stdio.StandardIO known?

Alexey 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.
 $ ./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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: program.py
Type: text/x-python
Size: 1515 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20100729/4f3d90d0/attachment.py 

More information about the Twisted-Python mailing list