Releases: amphp/parallel
1.4.1
What's Changed
- Replace Artax with http-client by @ishan-biztech and @voku in #135 and #136
- PHP 8 support by @danog in #138
- PHP 8.1 support by @kelunik
New Contributors
- @ishan-biztech made their first contribution in #135
- @voku made their first contribution in #136
- @danog made their first contribution in #138
Full Changelog: v1.4.0...v1.4.1
1.4.0
- Added a new parameter accepting an
Amp\Serialization\Serializer
instance to the constructor ofChannelledStream
,ChannelledSocket
, andSharedMemoryParcel
using the newamphp/serialization
library. This new parameter allows the serialization algorithm to be customized (e.g., using JSON or allowing only strings instead of only PHP built-in serializer). - Fixed serializing exception stack trace if arguments were disabled. (#109)
- Fixed the return value of
Worker::isRunning()
when a worker crashes. (#110) - When a worker crashes, a warning is now triggered. This warning may be logged for debugging failing workers. (#110)
- Fixed error when unwrapping shared memory when the original is moved during the read. (#100)
- Improved exception message when a
Task
return value is not serializable. (#103) - Updated shared memory message errors. (#100)
- Improved launching many processes/workers on certain systems. (#112)
1.3.0
- PHP 7.1+ now required.
- Improved cleanup of temporary files for IPC server (#82).
- Improved error message when a callable cannot be autoloaded (#83).
- Added
ContextPanicError
which extends the now-deprecatedPanicError
. This class contains improved methods for retrieving the original class name, exception message, code, and flattened stack trace of exceptions thrown in the child process or thread. - Added
TaskFailureException
andTaskFailureError
, extendingTaskException
andTaskError
respectively, which are now deprecated, to improve error reporting from workers. These classes are similar toContextPanicError
with improvements to retrieving information about the original exception. - Added
ContextFactory
and functionsAmp\Parallel\Context\create()
andAmp\Parallel\Context\run()
to create a context automatically based on installed extensions (i.e., a child process or a thread if ext-parallel is installed). - Fixed killing a child process if starting the process failed (#96).
1.2.0
- Added support for ext-parallel for thread contexts and workers.
- Added
BootstrapWorkerFactory
which includes a user-defined file when a worker is created. This is useful for including a custom autoloader or other bootstrapping logic. - Added an optional bootstrap file path to
WorkerProcess
andWorkerThread
constructors. - Improved stack traces reported from uncaught exceptions in contexts to report the stack trace of any previous exception.
- Contexts now define a
AMP_CONTEXT
constant for identifying what type of context is running and aAMP_CONTEXT_ID
constant, a unique integer identifier for that context. ChannelledSocket
hasreference()
andunreference()
methods that reference and unreference the underlying socket in the event loop.
1.1.1
- Improved the error message received in the parent process if the child process exits without resolving a promise or coroutine returned from the process callback.
- Fixed an issue where killing a child process would not fail any pending promises returned from
Process::join()
,Process::receive()
, orProcess::send()
. - Fixed regression in
1.1.0
of orphaned child processes resulting from a pool instance being destroyed. Be sure to callPool::shutdown()
to end worker processes gracefully.
1.1.0
- Added
Worker\CallableTask
andWorker\enqueueCallable()
function to execute serializable callables in a worker without defining a class implementingTask
. - The promise returned from
Context\Process::start()
now resolves to the process PID instead ofnull
. - Workers are now gracefully shutdown when a process exits (#68). Note that using
CTRL-C
immediately ends the PHP process, so workers are immediately killed. To gracefully shutdown workers or worker pools, a signal handler must be defined forSIGINT
/SIGTERM
to allow the PHP process to continue execution (even if that handler ends the process by stopping the event loop).
1.0.1
1.0.0
IPC has been greatly improved in this release. STDIN
and STDOUT
were previously used for process communication, redirecting child process output to STDERR
. However, this was often problematic for debugging and caused to confusion. Processes now used a dedicated socket for IPC, leaving the standard I/O streams available for for the user. These streams can be accessed on Context\Process
using getStdin()
, getStdout()
, and getStderr()
. No automatic forwarding of child output is done for Context\Process
. Worker\WorkerProcess
now automatically forwards STDOUT
and STDERR
to the parent STDOUT
and STDERR
. Using echo
, print
, printf()
, etc. in Worker\Task::run()
is still not recommended as ordering is not guaranteed and interleaving is very possible. However, for debugging purposes these functions can be useful.
Users of this library that only used the Worker\Worker
or Worker\Pool
interfaces are unlikely to need to make any changes to their code to upgrade from 0.2.x
. Most other BC breaks are minor.
STDOUT
of the process run usingContext\Process
is no longer redirected toSTDERR
of the parent process.STDIN
,STDOUT
, andSTDERR
of the child process are now available as stream objects usinggetStdin()
,getStdout()
, andgetStderr()
.AbstractWorker
has been renamed toTaskWorker
. The protected methodcancel()
was removed.- Subsequent calls to
Worker::shutdown()
now return the same promise as the first call. Prior, subsequent calls would throw an exception. Context\Context::start()
now returns a promise that is resolved once the context starts (or fails to start).Context\Process::run()
now returns a promise resolving to the instance ofContext\Process
created.Context\Thread::run()
now returns a promise resolving to the instance ofContext\Thread
created.Context\Thread::supported()
has been renamed toContext\Thread::isSupported()
.- Most classes in this library are now marked as final. (Composition over inheritance!)
- Error messages when tasks return unserializable data have been improved.
- Custom exception constructors skipping the code argument have been dropped in favor of using the standard constructor.
Worker\Environment::exists()
now declaresbool
as a return type (implementations should have always returned abool
, but is now declared in the interface).Worker\Pool::get()
has been renamed toWorker\Pool::getWorker()
.- The function
Worker\get()
has been renamed toWorker\worker()
.