[ASYNC] Running several "run_full_and_error" in parallel

9 views
Skip to first unread message

Paolo Donadeo

unread,
Sep 13, 2014, 12:04:53 PM9/13/14
to Core mailing list
I'm writing a simple script to run mplayer on my MP3 library, to collect stdout and stderr, to detect corrupted files.

In this moment I simply iterate over a list of strings (file names) and run mplayer using Async_shell.run_full_and_error.

Is there a way to run several instances of mplayer concurrently, to speed up the process using my 8-core processor?

I tried Throttle but, as always, I'm probably misusing the library, and Throttle.enqueue waits the termination of each mplayer "task".

Thanks.


P.S. The lesson here is that, once you discover Async, you cannot live without, even for trivial tasks :-)

--
Paolo

Ralph Douglass

unread,
Sep 13, 2014, 12:07:04 PM9/13/14
to ocaml...@googlegroups.com
Deferred.List.iter or something like that is what you probably want to take a look at
--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Ralph

Stephen Weeks

unread,
Sep 13, 2014, 3:21:26 PM9/13/14
to ocaml...@googlegroups.com
Also, check out the [~max_concurrent_jobs] argument to [Throttle.create].

Paolo Donadeo

unread,
Sep 13, 2014, 6:46:00 PM9/13/14
to Core mailing list
Thanks Ralph and Stephen, it works like a charm!


--
Paolo
Reply all
Reply to author
Forward
0 new messages