Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #206444

Re: Flushing all Buffers Before Exiting

From "Martin McCormick" <martin.m@suddenlink.net>
Newsgroups linux.debian.user
Subject Re: Flushing all Buffers Before Exiting
Date 2019-03-22 02:00 +0100
Message-ID <xEgHn-BF-3@gated-at.bofh.it> (permalink)
References <xE6ym-33l-13@gated-at.bofh.it> <xE71o-3cP-11@gated-at.bofh.it> <xE8Tw-4ld-13@gated-at.bofh.it> <xEaLD-5tc-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


David Wright <deblis@lionunicorn.co.uk> writes:
> An efficient way of doing this is to trap a signal, like USR1,
> in your program, and react by either your close/open-append or
> just flushing the buffers. That way, the program will run
> normally most of the time, without wasting all that time
> opening/closing files.
> 
> If there's not too much output compared with the computation necessary
> to generate it, just setting line-buffering on the output stream
> can be sufficient.
> 
> I've read that when the program is already running, some languages
> (like Python, so probably Perl too) offer a debugger that can
> allow you to flush the buffers from "within", but I've not tried
> it.
> 
> Cheers,
> David.

	Before reading this posting, I added code in my perl
script to open, append and close the file but the suggestion to
add a signal handler is a much better idea so thanks for the
suggestion.

	Opening, appending and closing for each new line of
output made me a bit squeamish.  The program is monitoring a
stream of data from a radio scanner.  The data spew in at about
20 or 30 lines per second.  When nothing is happening, there are
3 possible strings that indicate nothing is happening right now.
When something changes, the strings stop matching 3 comparison
strings i put in which match each of the 3 "nothing is happening
right now" strings and the different strings get printed to the
screen and to the disk.  In reality, these strings don't exactly
mean that nothing is happening but that the same non events are
happening.

	When things change and there is output of interest, that
output also spews in at 20 or 30 lines per second so I need to do
as little as possible to handle that so the system doesn't get
swamped.  The signal handler is most likely far more efficient a
method to capture the data of interest as it will essentially not
have to make any decisions until time to shut down the program
and look at the data.

	Even with the open, append and close routine, the strings
it is capturing appear to be good but it could be capturing for
minutes on end at times and it needs to just be able to run like
the wind and store lines as quickly as it can.

	Thank you.

Martin McCormick 
amateur radio WB5AGZ

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-21 15:10 +0100
  Re: Flushing all Buffers Before Exiting Kenneth Parker <sea7kenp@gmail.com> - 2019-03-21 15:40 +0100
    Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-21 16:20 +0100
      Re: Flushing all Buffers Before Exiting Curt <curty@free.fr> - 2019-03-21 19:10 +0100
        Re: Flushing all Buffers Before Exiting Greg Wooledge <wooledg@eeg.ccf.org> - 2019-03-21 19:20 +0100
        Re: Flushing all Buffers Before Exiting Luís Gomes <luismsgomes@gmail.com> - 2019-03-21 19:30 +0100
    Re: Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-21 17:40 +0100
      Re: Flushing all Buffers Before Exiting Greg Wooledge <wooledg@eeg.ccf.org> - 2019-03-21 17:50 +0100
        Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-21 18:30 +0100
      Re: Flushing all Buffers Before Exiting David Wright <deblis@lionunicorn.co.uk> - 2019-03-21 19:40 +0100
        Re: Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-22 02:00 +0100
          Re: Flushing all Buffers Before Exiting deloptes <deloptes@gmail.com> - 2019-03-22 06:20 +0100
          Re: Flushing all Buffers Before Exiting "Jeremy Nicoll" <jn.ml.dbn.25@letterboxes.org> - 2019-03-22 17:40 +0100
          Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-22 17:50 +0100
            Re: Flushing all Buffers Before Exiting David Wright <deblis@lionunicorn.co.uk> - 2019-03-23 16:30 +0100
              Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-23 18:30 +0100
                Re: Flushing all Buffers Before Exiting David Wright <deblis@lionunicorn.co.uk> - 2019-03-24 17:20 +0100
                Re: Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-24 19:30 +0100
                Re: Flushing all Buffers Before Exiting Gene Heskett <gheskett@shentel.net> - 2019-03-24 20:00 +0100
                Re: Flushing all Buffers Before Exiting deloptes <deloptes@gmail.com> - 2019-03-24 21:40 +0100
                Re: Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-25 03:00 +0100
                Re: Flushing all Buffers Before Exiting deloptes <deloptes@gmail.com> - 2019-03-25 07:20 +0100
                Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-25 10:50 +0100
                Re: Flushing all Buffers Before Exiting David Wright <deblis@lionunicorn.co.uk> - 2019-03-26 17:50 +0100
                Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-26 18:00 +0100
                Re: Flushing all Buffers Before Exiting Curt <curty@free.fr> - 2019-03-26 18:40 +0100
                Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-26 19:00 +0100
                Re: Flushing all Buffers Before Exiting David Wright <deblis@lionunicorn.co.uk> - 2019-03-27 16:00 +0100
                Re: Flushing all Buffers Before Exiting <tomas@tuxteam.de> - 2019-03-27 16:20 +0100
  Re: Flushing all Buffers Before Exiting Lee <ler762@gmail.com> - 2019-03-21 19:50 +0100
    Re: Flushing all Buffers Before Exiting "Martin McCormick" <martin.m@suddenlink.net> - 2019-03-23 22:40 +0100

csiph-web