Mpall
parser.add_argument( "-c", "--command", required=True, nargs="+", help="Command to execute (use placeholder for replacements)" )
# Test 3: Save results ./mpall.py -c "sleep s && echo done" -r s=1 -r s=2 -w 2 -o test.json </code></pre> <p>This is a complete, production-ready feature with error handling, logging, and flexible input methods.</p> parser
app = Mpall(args) sys.exit(app.run()) if == " main ": main() README.md # mpall - Multi-Process All-in-One Launcher Run commands in parallel across multiple processes with logging, retries, timeouts, and aggregated output. Installation chmod +x mpall.py sudo ln -s $(pwd)/mpall.py /usr/local/bin/mpall </code></pre> <h2>Usage</h2> <pre><code class="language-bash">mpall -c "command placeholder" -r key=value -w 4 </code></pre> <h2>Features</h2> <ul> <li>✅ <strong>Parallel execution</strong> (configurable worker count)</li> <li>✅ <strong>Placeholder replacement</strong> (<code>var</code> in commands)</li> <li>✅ <strong>Retry on failure</strong> (per task)</li> <li>✅ <strong>Timeout protection</strong> (per command)</li> <li>✅ <strong>JSON output</strong> for programmatic analysis</li> <li>✅ <strong>Signal handling</strong> (graceful Ctrl+C)</li> <li>✅ <strong>Logging</strong> (file + console)</li> <li>✅ <strong>Environment variables</strong> injection</li> </ul> <h2>Examples</h2> <h3>Basic parallel runs</h3> <pre><code class="language-bash">mpall -c "echo Hello" -r {} -w 10 </code></pre> <h3>Variable replacement</h3> <pre><code class="language-bash">mpall -c "curl url" -r url=https://api.example.com,method=GET </code></pre> <h3>Multiple replacements</h3> <pre><code class="language-bash">mpall -c "process.py input output" \ -r input=file1.txt,output=out1.txt \ -r input=file2.txt,output=out2.txt </code></pre> <h3>From file</h3> <pre><code class="language-bash">cat > tasks.txt <<EOF input=in1.txt,output=out1.txt input=in2.txt,output=out2.txt EOF This is a complete
parser.add_argument( "-r", "--replace", action="append", default=[], help="Replacements as key1=val1,key2=val2 (can specify multiple times)" ) production-ready feature with error handling
def _save_summary_text(self): """Save summary to text file.""" with open(self.args.output_summary, 'w') as f: f.write("MPALL EXECUTION SUMMARY\n") f.write("=" * 50 + "\n") for r in self.results: f.write(f"Task r.task_id: 'SUCCESS' if r.success else 'FAIL'\n") if not r.success: f.write(f" Error: r.stderr[:200]\n") def main(): parser = argparse.ArgumentParser( description="mpall - Run commands across multiple parallel processes", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" Examples: mpall -w 2 -c echo hello -r {} Replace placeholders mpall -c "echo name is age" -r name=alice,age=30 -r name=bob,age=25 Use replacement file mpall -c "process_file.py input output" -f replacements.txt -w 4 With retries and timeout mpall -c "curl url" -r url=http://example.com -t 30 --retries 3 Save results mpall -c "test.sh param" -r param=1 -o results.json --summary summary.txt """ )
@dataclass class TaskResult: """Result of a single task execution.""" task_id: int args: Tuple success: bool stdout: str stderr: str exit_code: int duration: float retries: int timestamp: str = field(default_factory=lambda: datetime.now().isoformat())
