Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

<Tazman> damn my office is cold. <Tazman> need a hot secretary to warm it up. -- Seen on #Linux


devel / comp.lang.tcl / Re: Reading a poor man's live feed

SubjectAuthor
* Reading a poor man's live feedLuc
+- Re: Reading a poor man's live feedpd
+* Re: Reading a poor man's live feedRich
|`* Re: Reading a poor man's live feedLuc
| `* Re: Reading a poor man's live feedRich
|  `* Re: Reading a poor man's live feedLuc
|   +- Re: Reading a poor man's live feedRalf Fassel
|   `* Re: Reading a poor man's live feedRich
|    `* Re: Reading a poor man's live feedLuc
|     `- Re: Reading a poor man's live feedRich
`- Re: Reading a poor man's live feedrene

1
Reading a poor man's live feed

<20240206195528.4e248150@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13290&group=comp.lang.tcl#13290

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Reading a poor man's live feed
Date: Tue, 6 Feb 2024 19:55:28 -0300
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20240206195528.4e248150@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="5f450366407e4f4420dca1909815d765";
logging-data="1154218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193fjXPRngRe+N2B/AbMFuytac3WzAt+lk="
Cancel-Lock: sha1:eFh2vAQBkhcqnRxwhyH1MHaCRi4=
 by: Luc - Tue, 6 Feb 2024 22:55 UTC

There is a file being constantly rewritten at /dev/shm that I need to
read from Tcl. Likely many times per second. I don't want it to miss
a beat.

My first idea:

while 1 {
set fp [open file r]
set content [read $fp
close $fp
}

Somehow I suspect this is a bad idea. Probably inefficient or maybe
even dangerous (due to lock ups)?

What do you think? Is there a better way?

--
Luc
>>

Re: Reading a poor man's live feed

<dbced05f-9a29-4dbb-9cf8-ecb4a5344f66n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13291&group=comp.lang.tcl#13291

  copy link   Newsgroups: comp.lang.tcl
X-Forwarded-Encrypted: i=1; AJvYcCVt82boYVafk2+a91J3CNBHHo7X2/uNFXecPMdVoAdXuKc2nt/f+8iqfRrzZw0sxk451rHumZV48k/kZI/W7DwuUKkmTrurrzR4GQoweyCTfOY=
X-Received: by 2002:ac8:58c1:0:b0:42c:b51:4631 with SMTP id u1-20020ac858c1000000b0042c0b514631mr339851qta.9.1707262108717;
Tue, 06 Feb 2024 15:28:28 -0800 (PST)
X-Forwarded-Encrypted: i=1; AJvYcCU/AoVOYwpeGzavRoMBPWArM9VgVRZTkQ9Kda3JNQFGxaexta/Ahw6IajFI1J+AedkdZeVmah4MezaFOOfH2yWQzXO9tbC7LcM/mJaIwe/J
X-Received: by 2002:ac8:574e:0:b0:42c:3f43:dd88 with SMTP id
14-20020ac8574e000000b0042c3f43dd88mr14520qtx.8.1707262108446; Tue, 06 Feb
2024 15:28:28 -0800 (PST)
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 6 Feb 2024 15:28:28 -0800 (PST)
In-Reply-To: <20240206195528.4e248150@lud1.home>
Injection-Info: google-groups.googlegroups.com; posting-host=207.188.184.151; posting-account=fwjo5QoAAAAcS9TSqEAQL1VEl7b8nCOq
NNTP-Posting-Host: 207.188.184.151
References: <20240206195528.4e248150@lud1.home>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dbced05f-9a29-4dbb-9cf8-ecb4a5344f66n@googlegroups.com>
Subject: Re: Reading a poor man's live feed
From: eukelade@gmail.com (pd)
Injection-Date: Tue, 06 Feb 2024 23:28:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1677
 by: pd - Tue, 6 Feb 2024 23:28 UTC

El martes, 6 de febrero de 2024 a las 23:55:33 UTC+1, Luc escribió:

> Somehow I suspect this is a bad idea. Probably inefficient or maybe
> even dangerous (due to lock ups)?
>
> What do you think? Is there a better way?

Maybe a file event be a better way

Re: Reading a poor man's live feed

<upuoin$14p58$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13293&group=comp.lang.tcl#13293

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Wed, 7 Feb 2024 02:06:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <upuoin$14p58$1@dont-email.me>
References: <20240206195528.4e248150@lud1.home>
Injection-Date: Wed, 7 Feb 2024 02:06:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40a4003fff8ac5422ce54c2e7458b9fc";
logging-data="1205416"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AtPJpYyyh+StThCIxrVJn"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:NZBrlmLHjJdT4XvWOzIYmKpVUHQ=
 by: Rich - Wed, 7 Feb 2024 02:06 UTC

Luc <luc@sep.invalid> wrote:
> There is a file being constantly rewritten at /dev/shm that I need to
> read

This is not going to work out well in the end. Sometimes you will get
the contents, sometimes you'll get an empty file, sometimes you may get
partial contents. And every now and then, seemingly at random, you'll
find there is no file present at all.

> from Tcl. Likely many times per second. I don't want it to miss
> a beat.

Yeah, good luck with that (many times a second). You'd have a hard
time keeping consistency with a speedy C program, but you'll very
likely quickly find this is a bad idea overall, and the overhead of the
Tcl interpreter will not help.

> My first idea:
>
> while 1 {
> set fp [open file r]
> set content [read $fp
> close $fp
> }
>
> Somehow I suspect this is a bad idea.

It is.

> Probably inefficient

It is.

> or maybe even dangerous (due to lock ups)?

Under linux you won't encounter lockups, but you will encounter all
possibilibites from "not there" up to missing some data.

Under windows you'll run smack into windows mandatory file locking and
encounter either lockups or outright refusal to open.

> What do you think? Is there a better way?

The only way for us to formulate an answer to that question is for you
to tell us what you are really trying to do, instead of this Rube
Goldberg machine you've presently described.

Re: Reading a poor man's live feed

<20240207002956.158b9e73@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13295&group=comp.lang.tcl#13295

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Wed, 7 Feb 2024 00:29:56 -0300
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <20240207002956.158b9e73@lud1.home>
References: <20240206195528.4e248150@lud1.home>
<upuoin$14p58$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="3d26cfc9949d8a99f97aa94b02a69f58";
logging-data="1353049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1934q9AxcQ5wJ18JuzIZZSc84wFGuB9Yjc="
Cancel-Lock: sha1:8LItIt24kX6ifkhKZSqVE4K90NI=
 by: Luc - Wed, 7 Feb 2024 03:29 UTC

On Wed, 7 Feb 2024 02:06:15 -0000 (UTC), Rich wrote:

>Under linux you won't encounter lockups, but you will encounter all
>possibilibites from "not there" up to missing some data.

I've been watching the "Rube Goldberg machine" as you describe it :-)
and never had a case of incomplete data. But missing file quite a few
times. I had to wrap catch around it.

But the machine froze and became unresponsive on two occasions. I had
to hard reset!

>> What do you think? Is there a better way?
>
>The only way for us to formulate an answer to that question is for you
>to tell us what you are really trying to do, instead of this Rube
>Goldberg machine you've presently described.

It's a Windows application running on Wine. It can log torrents of data
and I want to monitor that data, possibly triggering alarms. It's the
only way I can make it communicate with Tcl. At least I'm not making it
write to disk.

Would a Linux socket be more suitable? With Tcl socket capabilities?

--
Luc
>>

Re: Reading a poor man's live feed

<upv1e8$19o61$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13296&group=comp.lang.tcl#13296

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Wed, 7 Feb 2024 04:37:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <upv1e8$19o61$1@dont-email.me>
References: <20240206195528.4e248150@lud1.home> <upuoin$14p58$1@dont-email.me> <20240207002956.158b9e73@lud1.home>
Injection-Date: Wed, 7 Feb 2024 04:37:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40a4003fff8ac5422ce54c2e7458b9fc";
logging-data="1368257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19syRKohoybsrF96oScPduu"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:MVvOBj/UyODg82H/GXJQbhDjSh0=
 by: Rich - Wed, 7 Feb 2024 04:37 UTC

Luc <luc@sep.invalid> wrote:
> On Wed, 7 Feb 2024 02:06:15 -0000 (UTC), Rich wrote:
>
>>Under linux you won't encounter lockups, but you will encounter all
>>possibilibites from "not there" up to missing some data.
>
> I've been watching the "Rube Goldberg machine" as you describe it :-)
> and never had a case of incomplete data. But missing file quite a few
> times. I had to wrap catch around it.
>
> But the machine froze and became unresponsive on two occasions. I had
> to hard reset!
>
>
>>> What do you think? Is there a better way?
>>
>>The only way for us to formulate an answer to that question is for you
>>to tell us what you are really trying to do, instead of this Rube
>>Goldberg machine you've presently described.
>
> It's a Windows application running on Wine. It can log torrents of data
> and I want to monitor that data, possibly triggering alarms. It's the
> only way I can make it communicate with Tcl. At least I'm not making it
> write to disk.

Does it (the windows app) actually 'rewrite' the file (as in delete and
create another, or rewind to zero length and start writing again)?

If yes, you don't have a lot of choices, the 'rewriting' part is going
to cause you all kinds of pain.

> Would a Linux socket be more suitable? With Tcl socket capabilities?

If it is a 'log file' in the usual sense (opens, then a constant
torrent of writes occur) you might be able to point it at a named pipe
(read the 'man fifo' man-page) then open the named pipe in Tcl and just
read out the data it writes.

Alternately, if it won't write to a fifo then let it log to a disk file
somewhere and just use "tail -f" on the log file to ship the contents
into Tcl. I.e.:

set fd [open {|tail -f /tmp/logfile} RDONLY]

while {[gets $fd line] > -1} {
#do something with $line
}

Or setup file events on $fd and let the event loop trigger when the
file has data to read.

Re: Reading a poor man's live feed

<03b10cf0-2d67-4bf7-aa14-f453e5244039n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13298&group=comp.lang.tcl#13298

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:250:b0:42c:41b8:dad4 with SMTP id c16-20020a05622a025000b0042c41b8dad4mr35262qtx.5.1707304591247;
Wed, 07 Feb 2024 03:16:31 -0800 (PST)
X-Received: by 2002:ac8:5912:0:b0:42c:1bc9:4e69 with SMTP id
18-20020ac85912000000b0042c1bc94e69mr248352qty.12.1707304590797; Wed, 07 Feb
2024 03:16:30 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 7 Feb 2024 03:16:30 -0800 (PST)
In-Reply-To: <20240206195528.4e248150@lud1.home>
Injection-Info: google-groups.googlegroups.com; posting-host=212.243.175.74; posting-account=cY1uRgoAAAD1PpfCHRSABChlMQs7_rU7
NNTP-Posting-Host: 212.243.175.74
References: <20240206195528.4e248150@lud1.home>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <03b10cf0-2d67-4bf7-aa14-f453e5244039n@googlegroups.com>
Subject: Re: Reading a poor man's live feed
From: r.zaumseil@gmail.com (rene)
Injection-Date: Wed, 07 Feb 2024 11:16:31 +0000
Content-Type: text/plain; charset="UTF-8"
 by: rene - Wed, 7 Feb 2024 11:16 UTC

Luc schrieb am Dienstag, 6. Februar 2024 um 23:55:33 UTC+1:
> There is a file being constantly rewritten at /dev/shm that I need to
> read from Tcl. Likely many times per second. I don't want it to miss
> a beat.
>
> My first idea:
>
> while 1 {
> set fp [open file r]
> set content [read $fp
> close $fp
> }
>
> Somehow I suspect this is a bad idea. Probably inefficient or maybe
> even dangerous (due to lock ups)?
>
> What do you think? Is there a better way?
>
> --
> Luc
> >>
You could try "tko::file::tail" from https://chiselapp.com/user/rene/repository/tko/file?name=library/tko_file.tcl&ci=b597f7efa44e7ad53e11018f743e183b6cf69c1a9c2bcd0ef2d449b25cb480d0

Rene

Re: Reading a poor man's live feed

<20240208010608.6ea00112@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13303&group=comp.lang.tcl#13303

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Thu, 8 Feb 2024 01:06:08 -0300
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20240208010608.6ea00112@lud1.home>
References: <20240206195528.4e248150@lud1.home>
<upuoin$14p58$1@dont-email.me>
<20240207002956.158b9e73@lud1.home>
<upv1e8$19o61$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="88c8871fde3a65e25c07522a85f98371";
logging-data="1926672"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/H/PYUCUHi2v+Nv92YpPN7JYlEzr+lzV8="
Cancel-Lock: sha1:VTCFvcvn/rxG8qP5xin251vXIsM=
 by: Luc - Thu, 8 Feb 2024 04:06 UTC

On Wed, 7 Feb 2024 04:37:29 -0000 (UTC), Rich wrote:

>Does it (the windows app) actually 'rewrite' the file (as in delete and
>create another, or rewind to zero length and start writing again)?

I don't know. Is there a way to find out?

I've seen my Tcl script error out (before I added 'catch') complaining
that the file was not found so I guess it is deleted and rewritten from
scracth every time. But it's just my guess.

> set fd [open {|tail -f /tmp/logfile} RDONLY]
>
> while {[gets $fd line] > -1} {
> #do something with $line
> }

That code doesn't work. No output. I only get output with my previous
approach:

proc every {ms body} {
eval $body
after $ms [info level 0]
}

every 1 {
catch {p.loop}
}

proc p.loop {} {
if {![file exists $::feedfile]} {return}
set fp [open $::feedfile r]
set data [read $fp]
puts $data
}

--
Luc
>>

Re: Reading a poor man's live feed

<ygawmrfmhbx.fsf@panther.akutech-local.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13306&group=comp.lang.tcl#13306

  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: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Thu, 08 Feb 2024 10:32:50 +0100
Lines: 26
Message-ID: <ygawmrfmhbx.fsf@panther.akutech-local.de>
References: <20240206195528.4e248150@lud1.home> <upuoin$14p58$1@dont-email.me>
<20240207002956.158b9e73@lud1.home> <upv1e8$19o61$1@dont-email.me>
<20240208010608.6ea00112@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net e0dltdtgNkjwAnQLi17U+wynzEUu/e0HP/lb9s4596oj28IWw=
Cancel-Lock: sha1:lw/oqsoqIipFdl5hLjxb7vkkrNM= sha1:WksvkzHcWVnblmGJaVoN1CpkIEQ= sha256:QANBtyv9pl9njtOZM1taYZud/cLVscPMNnrDjKoF4Nk=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 8 Feb 2024 09:32 UTC

* Luc <luc@sep.invalid>
| proc p.loop {} {
| if {![file exists $::feedfile]} {return}
| set fp [open $::feedfile r]

Note that there still is a chance that [file exists] returns true and
the [open] failing due to ENOENT (file has been removed between the two
calls).

A more robust approach is to simply open the file and handle ENOENT, see
the 'try' manpage for an example:

Handle different reasons for a file to not be openable for reading:

try {
set f [open /some/file/name w]
} trap {POSIX EISDIR} {} {
puts "failed to open /some/file/name: it's a directory"
} trap {POSIX ENOENT} {} {
puts "failed to open /some/file/name: it doesn't exist"
}

HTH
R'

Re: Reading a poor man's live feed

<uq39ce$23gul$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13316&group=comp.lang.tcl#13316

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Thu, 8 Feb 2024 19:17:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <uq39ce$23gul$2@dont-email.me>
References: <20240206195528.4e248150@lud1.home> <upuoin$14p58$1@dont-email.me> <20240207002956.158b9e73@lud1.home> <upv1e8$19o61$1@dont-email.me> <20240208010608.6ea00112@lud1.home>
Injection-Date: Thu, 8 Feb 2024 19:17:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0a76cb11b3417798b83a271d819990b2";
logging-data="2212821"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Q0YIlP1ot414tJhMivd44"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:5q5fgKp5Hk2tZyIYBGKr6m4Hgew=
 by: Rich - Thu, 8 Feb 2024 19:17 UTC

Luc <luc@sep.invalid> wrote:
> On Wed, 7 Feb 2024 04:37:29 -0000 (UTC), Rich wrote:
>
>>Does it (the windows app) actually 'rewrite' the file (as in delete and
>>create another, or rewind to zero length and start writing again)?
>
> I don't know. Is there a way to find out?

You could strace wine while the windows app is logging and see what
file access calls are being made.

> I've seen my Tcl script error out (before I added 'catch')
> complaining that the file was not found so I guess it is deleted and
> rewritten from scracth every time. But it's just my guess.
>
>> set fd [open {|tail -f /tmp/logfile} RDONLY]
>>
>> while {[gets $fd line] > -1} {
>> #do something with $line
>> }
>
> That code doesn't work. No output. I only get output with my previous
> approach:

That implies a delete and recreate approach (which is an odd way to do
it, but it /is/ a windows program, so....), which will be *much* harder
for you to keep up with.

Re: Reading a poor man's live feed

<20240209180737.6a128245@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13329&group=comp.lang.tcl#13329

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Fri, 9 Feb 2024 18:07:37 -0300
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <20240209180737.6a128245@lud1.home>
References: <20240206195528.4e248150@lud1.home>
<upuoin$14p58$1@dont-email.me>
<20240207002956.158b9e73@lud1.home>
<upv1e8$19o61$1@dont-email.me>
<20240208010608.6ea00112@lud1.home>
<uq39ce$23gul$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="b32f7956cb72b4499fdf21f9f1af1ba3";
logging-data="2945820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PBWA2OicrB1JyzRqYf/NuoWpQBLJpD8U="
Cancel-Lock: sha1:peDA+hDu0+euJDMuSbqr3DdwH80=
 by: Luc - Fri, 9 Feb 2024 21:07 UTC

On Thu, 8 Feb 2024 19:17:34 -0000 (UTC), Rich wrote:

>> That code doesn't work. No output. I only get output with my previous
>> approach:
>
>That implies a delete and recreate approach (which is an odd way to do
>it, but it /is/ a windows program, so....), which will be *much* harder
>for you to keep up with.

I was going to give up because it's just an experiment, but something
odd is happening and I would like to understand it.

set feedfile "/dev/shm/myfeed.txt"
set fifofile "/dev/shm/myfeed.fifo"
exec tail -f $feedfile > $fifofile &

(build Tk GUI with text widget to display the data)

while {[gets $fd line] > -1} {
puts $line
return

(text widget insertion here, not in use yet, return aborts it)
}

I get no output. Nothing happens.

Then I go to the directory where the fifo file is in a regular shell
terminal:

$ cat myfeed.fifo

After running that command, I get all the output (ok, makes sense) but:

1. Only in the shell terminal, not in the IDE's compiler output pane
which usually captures the output.
2. AND the Tk GUI with the text widget shows up on the screen. Empty,
but visible.

Why?

Moreover, if I remove the 'return' line, then the IDE captures the
output (because of the 'puts' line), but the Tk GUI never shows up.

Again, why?

--
Luc
>>

Re: Reading a poor man's live feed

<uq6vvj$31qv4$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13330&group=comp.lang.tcl#13330

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Reading a poor man's live feed
Date: Sat, 10 Feb 2024 05:01:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <uq6vvj$31qv4$1@dont-email.me>
References: <20240206195528.4e248150@lud1.home> <upuoin$14p58$1@dont-email.me> <20240207002956.158b9e73@lud1.home> <upv1e8$19o61$1@dont-email.me> <20240208010608.6ea00112@lud1.home> <uq39ce$23gul$2@dont-email.me> <20240209180737.6a128245@lud1.home>
Injection-Date: Sat, 10 Feb 2024 05:01:39 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0482dfb52062f178359b1afea1faa5e";
logging-data="3206116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BuJ5rwCFNNyS6akNS7oVQ"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:FmpCJ+/OXrGZseK0BhCMk5+MK68=
 by: Rich - Sat, 10 Feb 2024 05:01 UTC

Luc <luc@sep.invalid> wrote:
> On Thu, 8 Feb 2024 19:17:34 -0000 (UTC), Rich wrote:
>
>>> That code doesn't work. No output. I only get output with my previous
>>> approach:
>>
>>That implies a delete and recreate approach (which is an odd way to
>>do it, but it /is/ a windows program, so....), which will be *much*
>>harder for you to keep up with.
>
> I was going to give up because it's just an experiment, but something
> odd is happening and I would like to understand it.
>
>
> set feedfile "/dev/shm/myfeed.txt"
> set fifofile "/dev/shm/myfeed.fifo"
> exec tail -f $feedfile > $fifofile &

If using tail to copy from the wine created 'feed' to the fifo works
(you say it does when you indicate you 'cat' the fifo below) then you
should just be able to open the feed file and read/gets from it.

> (build Tk GUI with text widget to display the data)
>
> while {[gets $fd line] > -1} {
> puts $line
> return
>
> (text widget insertion here, not in use yet, return aborts
> it)
> }
>
> I get no output. Nothing happens.

That while loop above only ever runs for one iteration because of the
'return'. I suspect you meant to use 'continue' not 'return'.

> Then I go to the directory where the fifo file is in a regular shell
> terminal:
>
> $ cat myfeed.fifo
>
> After running that command, I get all the output (ok, makes sense)
> but:
>
> 1. Only in the shell terminal, not in the IDE's compiler output pane
> which usually captures the output.

If the code you posted here is the same you are running in the IDE,
then only running the while for a singe gets/puts iteration is why.

> 2. AND the Tk GUI with the text widget shows up on the screen. Empty,
> but visible.
>
> Why?

Because the return terminates the while loop.

> Moreover, if I remove the 'return' line, then the IDE captures the
> output (because of the 'puts' line), but the Tk GUI never shows up.
>
> Again, why?

Because the while loop never lets the event loop run. With the event
loop paused no Tk GUI will ever show up.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor