Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TomasVotruba/parallel-process

Open more actions menu
 
 

Repository files navigation

Parallel Process

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Run multiple Synfony\Process's at the same time.

giphy

Install

Via Composer

$ composer require graze/parallel-process

Usage

$failure = function (Process $process, $duration) {
    throw new ProcessFailureException($process);
}

$pool = new Pool();
$pool->setOnFailure($failure);
$pool->add(new Process('sleep 100'));
$pool->add(new Process('sleep 100'));
$pool->add(new Process('sleep 100'));
$pool->add(new Process('sleep 100'));
$pool->add(new Process('sleep 100'));
$pool->run(); // blocking that will run till it finishes

Table

Visual output of the parallel processes

$table = new Table($output);
for ($i = 0; $i < 5; $i++) {
    $time = $i + 5;
    $table->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' => $time]);
}
$table->run();

asciicast

Lines

Write the output of each process to the screen

$pool = new \Graze\ParallelProcess\Pool();
$pool->setMaxSimultaneous(3);
$lines = new Lines($output, $pool);
for ($i = 0; $i < 5; $i++) {
    $time = $i + 5;
    $lines->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' . $time]);
}
$lines->run();

asciicast

Testing

$ make test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@graze.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

🏃 Run multiple processes simultaneously

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 97.0%
  • Makefile 3.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.