Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The Street finds its own uses for technology." -- William Gibson


devel / comp.lang.tcl / Using gets in nonblocking mode on a file not ending in a newline

SubjectAuthor
* Using gets in nonblocking mode on a file not ending in a newlineclt.to.davebr
`- Using gets in nonblocking mode on a file not ending in a newlineRalf Fassel

1
Using gets in nonblocking mode on a file not ending in a newline

<2911667752370@dlp>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10064&group=comp.lang.tcl#10064

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: clt.to.d...@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Using gets in nonblocking mode on a file not ending in a newline
Date: Sun, 06 Nov 22 16:32:50 GMT
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <2911667752370@dlp>
Injection-Info: reader01.eternal-september.org; posting-host="68d2a0e49adf33fcd23a167e7b9954e1";
logging-data="3354203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a2daVq+97G7HL3E7YPJOt"
Cancel-Lock: sha1:sJf9tTQIo9UMLMmQ2hAsh6yLfU0=
 by: clt.to.d...@dfgh.net - Sun, 6 Nov 2022 16:32 UTC

>non-blocking mode doesn't make much sense on a file. On a socket or
>command pipe, non-blocking is useful because if the sender decides not
>to send any data, you would otherwise wait infinitely long. A file is
>always ready. My guess is that you actually want to do something else.

I generally open a disk file using the default blocking mode, so the behavior
with files not ending in a newline is normally not a problem for me.
However one of my use cases is reading CSV data as it is being captured from a data logger.

I'm writing procs to split CSV data into a list of records (instead of a queue or matrix).
In looking a how this is done in the tcllib csv package I realized the code was written to gracefully handle nonblocking mode when using [gets]. A minor change in my code would make it more robust.

This kind of thing should be documented somewhere. I'd like to see what other best practices
and quirks are described there. If documentation does not exist, it needs to be created.

Dave B

Re: Using gets in nonblocking mode on a file not ending in a newline

<yga7d076pju.fsf@akutech.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10071&group=comp.lang.tcl#10071

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Using gets in nonblocking mode on a file not ending in a newline
Date: Mon, 07 Nov 2022 11:12:53 +0100
Lines: 27
Message-ID: <yga7d076pju.fsf@akutech.de>
References: <2911667752370@dlp>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net IQ49vAt6uMvvXQzuz9EqhAmaNnekmP+hm+Wq5VaCo1i9CL8vE=
Cancel-Lock: sha1:0i9c8UJSBYpAEGH4KzgFP/NrPrc= sha1:ZPr2HAPtLf2FyD1YaPOGsO28F48=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Mon, 7 Nov 2022 10:12 UTC

* clt.to.davebr@dfgh.net
| >non-blocking mode doesn't make much sense on a file. On a socket or
| >command pipe, non-blocking is useful because if the sender decides not
| >to send any data, you would otherwise wait infinitely long. A file is
| >always ready. My guess is that you actually want to do something else.
>
| I generally open a disk file using the default blocking mode, so the
| behavior with files not ending in a newline is normally not a problem
| for me. However one of my use cases is reading CSV data as it is
| being captured from a data logger.

Are you reading from a pipe to the logger, or from a disk file which is
in parallel updated by the logger?

| In looking a how this is done in the tcllib csv package I realized the
| code was written to gracefully handle nonblocking mode when using
| [gets]. A minor change in my code would make it more robust.

Where do you see nonblocking mode in tcllib csv?
I don't see any 'fconfigure' commands in the module, only

while !eof
if gets < 0 continue

loops... (tcllib 1.20).

R'

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor