Groups | Search | Server Info | Login | Register
Groups > comp.lang.tcl > #55699
| From | Emiliano <emiliano@example.invalid> |
|---|---|
| Newsgroups | comp.lang.tcl |
| Subject | Re: Fastest way to run two external processes |
| Date | 2026-05-02 00:34 -0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <20260502003454.8ff155afa267a4ffc00d560a@example.invalid> (permalink) |
| References | <10sschf$3nvs2$1@dont-email.me> |
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 | Next — Previous in thread | Find similar
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