Groups | Search | Server Info | Login | Register


Groups > comp.lang.tcl > #55699

Re: Fastest way to run two external processes

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Emiliano <emiliano@example.invalid>
Newsgroups comp.lang.tcl
Subject Re: Fastest way to run two external processes
Date Sat, 2 May 2026 00:34:54 -0300
Organization A noiseless patient Spider
Lines 46
Message-ID <20260502003454.8ff155afa267a4ffc00d560a@example.invalid> (permalink)
References <10sschf$3nvs2$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Injection-Date Sat, 02 May 2026 03:34:57 +0000 (UTC)
Injection-Info dont-email.me; logging-data="2002997"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1938FfxkrzTZk80hFGz6p3wK6vFjdSnfno="; posting-host="ecf4187c85b01c660f29eed0267708f0"
Cancel-Lock sha1:SFxSLPOYT3G3sJCqwrcsWAjPd3w=
X-Newsreader Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
Xref csiph.com comp.lang.tcl:55699

Show key headers only | View raw


On Wed, 29 Apr 2026 07:38:23 -0000 (UTC)
Mark Summerfield <m.n.summerfield@gmail.com> wrote:

> I need to run two external processes (on Linux):
> 
> pdftotext -tsv one.pdf
> pdftotext -tsv two.pdf

You can use pipes and run the processes in the background, collecting output
with the event loop. Here's a rough draft

proc runit {var file} {
    lassign [chan pipe] cr cw
    exec pdftotext -tsv $file - >@ $cw &
    chan close $cw
    chan configure $cr -blocking 0
    chan event $cr readable [list handle $var $cr]
}
proc handle {var fd} {
    global $var
    append $var [chan read $fd]
    if {[chan eof $fd]} {
	chan close $fd
	set ::done 1
    }
}
puts "sequential: [time {
    set out1 [exec pdftotext -tsv one.pdf -]
    set out2 [exec pdftotext -tsv two.pdf -]
    puts "one.pdf [string length $out1]"
    puts "two.pdf [string length $out2]"
}]"
puts "parallel: [time {
    runit out1 one.pdf
    runit out2 two.pdf
    vwait done
    vwait done
    puts "one.pdf [string length $out1]"
    puts "two.pdf [string length $out2]"
}]"


Regards

-- 
Emiliano

Back to comp.lang.tcl | Previous | NextPrevious in thread | Find similar


Thread

Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-04-29 07:38 +0000
  Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-04-29 08:51 +0000
    Re: Fastest way to run two external processes meshparts <alexandru.dadalau@meshparts.de> - 2026-04-29 11:24 +0200
      Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-04-29 09:46 +0000
    Re: Fastest way to run two external processes Ralf Fassel <ralfixx@gmx.de> - 2026-04-29 12:30 +0200
      Re: Fastest way to run two external processes abu <user13892@newsgrouper.org.invalid> - 2026-04-30 00:51 +0000
        Re: Fastest way to run two external processes Ralf Fassel <ralfixx@gmx.de> - 2026-04-30 14:23 +0200
        Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-05-01 07:04 +0000
          Re: Fastest way to run two external processes Ralf Fassel <ralfixx@gmx.de> - 2026-05-01 22:54 +0200
            Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-05-02 06:57 +0000
              Re: Fastest way to run two external processes Ashok <apnmbx-public@yahoo.com> - 2026-05-09 16:03 +0530
                Re: Fastest way to run two external processes Ralf Fassel <ralfixx@gmx.de> - 2026-05-11 11:08 +0200
                Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-05-12 08:40 +0000
                Re: Fastest way to run two external processes Ralf Fassel <ralfixx@gmx.de> - 2026-05-12 16:58 +0200
                Re: Fastest way to run two external processes Mark Summerfield <m.n.summerfield@gmail.com> - 2026-05-13 08:54 +0000
  Re: Fastest way to run two external processes Olivier <user1108@newsgrouper.org.invalid> - 2026-05-01 10:06 +0000
  Re: Fastest way to run two external processes Emiliano <emiliano@example.invalid> - 2026-05-02 00:34 -0300

csiph-web