amphp / parallel

An advanced parallelization library for PHP, enabling efficient multitasking, optimizing resource use, and application responsiveness through multiple CPU threads.
MIT License
779 stars 64 forks source link

Expected a valid stream #185

Closed PNixx closed 1 year ago

PNixx commented 1 year ago

After update from v2.2.1 to v2.2.2 I catch more errors:

#0 vendor/amphp/byte-stream/src/functions.php(107): Amp\ByteStream\WritableResourceStream->__construct()
#1 vendor/amphp/parallel/src/Context/DefaultContextFactory.php(42): Amp\ByteStream\getStdout()
#2 vendor/amphp/parallel/src/Worker/ContextWorkerFactory.php(43): Amp\Parallel\Context\DefaultContextFactory->start()
#3 vendor/amphp/parallel/src/Worker/ContextWorkerPool.php(243): Amp\Parallel\Worker\ContextWorkerFactory->create()
#4 vendor/amphp/amp/src/functions.php(34): Amp\Parallel\Worker\ContextWorkerPool::Amp\Parallel\Worker\{closure}()
#5 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(422): Amp\{closure}()
#6 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(558): Revolt\EventLoop\Internal\AbstractDriver->invokeMicrotasks()
#7 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#8 vendor/revolt/event-loop/src/EventLoop/Internal/DriverSuspension.php(54): Fiber->resume()
#9 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(422): Revolt\EventLoop\Internal\DriverSuspension::Revolt\EventLoop\Internal\{closure}()
#10 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(612): Revolt\EventLoop\Internal\AbstractDriver->invokeMicrotasks()
#11 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#12 vendor/revolt/event-loop/src/EventLoop/Internal/DriverSuspension.php(54): Fiber->resume()
#13 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(422): Revolt\EventLoop\Internal\DriverSuspension::Revolt\EventLoop\Internal\{closure}()
#14 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(612): Revolt\EventLoop\Internal\AbstractDriver->invokeMicrotasks()
#15 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#16 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(494): Fiber->resume()
#17 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(549): Revolt\EventLoop\Internal\AbstractDriver->invokeCallbacks()
#18 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#19 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(112): Fiber->resume()
#20 vendor/revolt/event-loop/src/EventLoop/Driver/EventDriver.php(119): Revolt\EventLoop\Internal\AbstractDriver->run()

STDOut and STDIn closed for my worker.

trowski commented 1 year ago

So you're closing STDOUT on your parent process? That's rather unexpected…

PNixx commented 1 year ago

I use pcntl_fork for workers. All logs write only to file.

trowski commented 1 year ago

So you fork a set of workers, which themselves then create workers with amphp/parallel?

PNixx commented 1 year ago

I use https://github.com/amphp/file and more libs from your framework.

trowski commented 1 year ago

I believe this issue is addressed by v2.0.2 of amphp/byte-stream. Please update and close the issue if that's the case.

PNixx commented 1 year ago

Thanks, it working