mirror of
https://github.com/danog/file.git
synced 2024-11-30 04:19:39 +01:00
Use separate pool for each parallel test
Shutdown the pool after each test to avoid spawning many workers.
This commit is contained in:
parent
32454e960b
commit
783ad03940
@ -2,12 +2,27 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\Worker\DefaultPool;
|
||||
|
||||
class ParallelDriverTest extends DriverTest {
|
||||
/** @var \Amp\Parallel\Worker\Pool */
|
||||
private $pool;
|
||||
|
||||
public function setUp() {
|
||||
$this->pool = new DefaultPool;
|
||||
$this->pool->start();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
Loop::run(function () {
|
||||
yield $this->pool->shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
protected function lRun(callable $cb) {
|
||||
\Amp\Loop::run(function() use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\ParallelDriver(new DefaultPool));
|
||||
\Amp\File\filesystem(new \Amp\File\ParallelDriver($this->pool));
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
}
|
||||
|
@ -2,12 +2,27 @@
|
||||
|
||||
namespace Amp\File\Test;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\Worker\DefaultPool;
|
||||
|
||||
class ParallelHandleTest extends HandleTest {
|
||||
/** @var \Amp\Parallel\Worker\Pool */
|
||||
private $pool;
|
||||
|
||||
public function setUp() {
|
||||
$this->pool = new DefaultPool;
|
||||
$this->pool->start();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
Loop::run(function () {
|
||||
yield $this->pool->shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
protected function lRun(callable $cb) {
|
||||
\Amp\Loop::run(function() use ($cb) {
|
||||
\Amp\File\filesystem(new \Amp\File\ParallelDriver(new DefaultPool));
|
||||
\Amp\File\filesystem(new \Amp\File\ParallelDriver($this->pool));
|
||||
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user