Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79410
| References | (2 earlier) <mailman.14970.1413653368.18130.python-list@python.org> <pan.2014.10.19.01.11.55.240000@nowhere.invalid> <CAGGBd_orhmCnFrsuA+sWHUwo5T7eXHmL49H2q6eyM4fUb+OksA@mail.gmail.com> <mailman.14978.1413682922.18130.python-list@python.org> <pan.2014.10.22.02.49.42.877000@nowhere.invalid> |
|---|---|
| Date | 2014-10-21 20:11 -0700 |
| Subject | Re: Flush stdin |
| From | Dan Stromberg <drsalists@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15054.1413947502.18130.python-list@python.org> (permalink) |
On Tue, Oct 21, 2014 at 7:49 PM, Nobody <nobody@nowhere.invalid> wrote:
> On Sat, 18 Oct 2014 18:42:00 -0700, Dan Stromberg wrote:
>
>> On Sat, Oct 18, 2014 at 6:34 PM, Dan Stromberg <drsalists@gmail.com> wrote:
>>>> Once the "nc" process actually write()s the data to its standard
>>>> output (i.e. desriptor 1, not the "stdout" FILE*)
>>> I'm not sure why you're excluding stdout, but even if nc is using
>>> filedes 1 instead of FILE * stdout, isn't it kind of irrelevant?
>>
>> On further reflection, isn't it stdio that does the varied buffering,
>> and filedes 1 that's always unbuffered? IOW, the OP might wish nc was
>> using 1, but it probably can't be given what they're seeing.
>
> Yes. stdio does buffering. Writing to stdout stores data in a buffer; that
> data should eventually be written to descriptor 1, although perhaps not
> until immediately prior to termination.
>
> Which is probably the cause of the OP's problem.
Huh. And here I thought I demonstrated elsewhere in this thread, that
the buffering between nc and python didn't appear to be the problem.
'found it, here it is again:
If I run the following in one tty:
nc -l localhost 9000 | /tmp/z
...where /tmp/z has just:
#!/usr/bin/python3
import sys
for line in sys.stdin.buffer:
print(line)
And then run the following in another tty on the same computer:
while read line; do echo $line; sleep 1; done < /etc/passwd | nc
localhost 9000
...then everything acts line buffered, or perhaps even character
buffered (the two are pretty indistinguishable in this test). What I
see is my /etc/passwd file popping out of the nc -l side, one line at
a time, each line one second apart.
I suppose this suggests that it's the client that's sending TCP data
that is buffering.
That, or we're using two different versions of netcat (there are at
least two available).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Flush stdin Empty Account <emptya45@gmail.com> - 2014-10-17 12:38 +0100
Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-18 17:55 +0100
Re: Flush stdin Tim Chase <python.list@tim.thechases.com> - 2014-10-18 12:32 -0500
Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-19 02:11 +0100
Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-18 18:34 -0700
Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-18 18:42 -0700
Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-22 03:49 +0100
Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-21 20:11 -0700
Re: Flush stdin MRAB <python@mrabarnett.plus.com> - 2014-10-18 18:55 +0100
Re: Flush stdin Cameron Simpson <cs@zip.com.au> - 2014-10-19 08:01 +1100
Re: Flush stdin Terry Reedy <tjreedy@udel.edu> - 2014-10-18 18:35 -0400
csiph-web