Skip to content

Releases: amphp/parallel

1.4.1

25 Oct 20:03
v1.4.1
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.4.0...v1.4.1

1.4.0

27 Apr 20:34
2c1039b
Compare
Choose a tag to compare
  • Added a new parameter accepting an Amp\Serialization\Serializer instance to the constructor of ChannelledStream, ChannelledSocket, and SharedMemoryParcel using the new amphp/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

23 Feb 15:40
346d3f5
Compare
Choose a tag to compare
  • 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-deprecated PanicError. 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 and TaskFailureError, extending TaskException and TaskError respectively, which are now deprecated, to improve error reporting from workers. These classes are similar to ContextPanicError with improvements to retrieving information about the original exception.
  • Added ContextFactory and functions Amp\Parallel\Context\create() and Amp\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

25 Jun 18:24
Compare
Choose a tag to compare
  • 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 and WorkerThread 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 a AMP_CONTEXT_ID constant, a unique integer identifier for that context.
  • ChannelledSocket has reference() and unreference() methods that reference and unreference the underlying socket in the event loop.

1.1.1

09 Jan 21:40
Compare
Choose a tag to compare
  • 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(), or Process::send().
  • Fixed regression in 1.1.0 of orphaned child processes resulting from a pool instance being destroyed. Be sure to call Pool::shutdown() to end worker processes gracefully.

1.1.0

30 Dec 19:35
ccf285b
Compare
Choose a tag to compare
  • Added Worker\CallableTask and Worker\enqueueCallable() function to execute serializable callables in a worker without defining a class implementing Task.
  • The promise returned from Context\Process::start() now resolves to the process PID instead of null.
  • 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 for SIGINT/SIGTERM to allow the PHP process to continue execution (even if that handler ends the process by stopping the event loop).

1.0.1

27 Oct 16:23
4c3c93e
Compare
Choose a tag to compare
  • Prevent forwarding of STDOUT and STDERR in WorkerProcess from keeping the event loop running when no other watchers are active.
  • Fixed DefaultPool::shutdown(), which now returns the same promise on subsequent calls.

1.0.0

27 Oct 15:14
d783e13
Compare
Choose a tag to compare

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 using Context\Process is no longer redirected to STDERR of the parent process. STDIN, STDOUT, and STDERR of the child process are now available as stream objects using getStdin(), getStdout(), and getStderr().
  • AbstractWorker has been renamed to TaskWorker. The protected method cancel() 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 of Context\Process created.
  • Context\Thread::run() now returns a promise resolving to the instance of Context\Thread created.
  • Context\Thread::supported() has been renamed to Context\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 declares bool as a return type (implementations should have always returned a bool, but is now declared in the interface).
  • Worker\Pool::get() has been renamed to Worker\Pool::getWorker().
  • The function Worker\get() has been renamed to Worker\worker().

0.2.5

21 Mar 14:49
v0.2.5
Compare
Choose a tag to compare
  • Fixed running inside PHARs if the PHAR doesn't have a .phar file extension.

0.2.4

14 Mar 23:56
ed36621
Compare
Choose a tag to compare
  • Added signal() and getPid() methods to Process returning the values from the encapsulated process.