Aaron Piotrowski
410c88e859
Serialize function arguments
...
Maybe this is a horrible idea, but we serialize everything else, so why not?
2019-02-14 00:34:45 -06:00
Aaron Piotrowski
ecaf0a854b
Add support for krakjoe/parallel
2019-02-14 00:34:45 -06:00
Aaron Piotrowski
c77843fa77
Catch parse error and provide better error message
2019-02-13 16:36:45 -06:00
Aaron Piotrowski
6b6e38cf70
Define constants in contexts for easy identification
2019-02-13 14:15:16 -06:00
Aaron Piotrowski
1ee8e202ed
Apply the same treatment to context exceptions
...
Sends info about previous exceptions thrown in the context to the parent.
2019-01-25 17:53:19 -06:00
Aaron Piotrowski
9236ade19f
Capture previous exceptions of exceptions thrown from Task::run()
2019-01-25 14:29:32 -06:00
Aaron Piotrowski
80c07011d6
Fix failing Process::join()
...
If the process is killed while joining, an exception was thrown from Process::kill().
2019-01-09 10:25:30 -06:00
Aaron Piotrowski
beafcdb140
Close channel in process when ended
...
Also restored destructor to DefaultPool to immediately kill workers instead of waiting until the end of the process.
2019-01-09 09:28:31 -06:00
Aaron Piotrowski
dc036dfa33
Use Promise\wait() in process-runner.php
2019-01-04 16:58:05 -06:00
Aaron Piotrowski
65d71c3526
Check for resolution of promise in process-runner.php
2019-01-04 16:46:53 -06:00
Aaron Piotrowski
f391d3549a
Improve error message when parent has exited
2018-12-30 13:08:38 -06:00
Aaron Piotrowski
2ac081575e
Wait for pending task in shutdown
2018-12-30 12:48:54 -06:00
Aaron Piotrowski
d7697ebd69
Gracefully shutdown workers on process exit
2018-12-30 12:38:17 -06:00
Aaron Piotrowski
1c9822a564
Fix #66
2018-12-19 18:47:43 -06:00
Pieter Hordijk
354e64db09
Fixed typo in exception message
...
When the process cannot be started it tells me "Staring the process failed".
You can stare at a process all you want, but it should be "Starting".
2018-11-08 14:29:35 -06:00
Aaron Piotrowski
596f41886b
Return PID from Process::start()
2018-11-04 11:34:18 -06:00
Niklas Keller
912047f2ec
Add CallableTask and enqueueCallable
2018-11-04 10:17:19 -06:00
Aaron Piotrowski
4c3c93e46a
Fix DefaultPool::shutdown()
...
Forgot to update this to match Worker::shutdown() behavior.
2018-10-27 11:19:01 -05:00
Aaron Piotrowski
eff56fb849
Unreference process I/O streams
2018-10-27 11:14:31 -05:00
Aaron Piotrowski
d783e13fa4
Store exit status promise
...
Return this promise from subsequent calls to shutdown().
2018-10-27 09:59:10 -05:00
Aaron Piotrowski
7961e6a13a
AbstractWorker → TaskWorker
2018-10-26 18:29:45 -05:00
Aaron Piotrowski
1c1d22b7f6
Pool::get() → Pool::getWorker()
...
Also renamed Worker\get() to Worker\pool()->getWorker().
2018-10-25 09:54:40 -05:00
Aaron Piotrowski
9098d26b56
Declare return type on exists()
2018-10-25 09:38:38 -05:00
Aaron Piotrowski
8caf8d4dce
Fix missed exception construct
2018-10-24 23:02:24 -05:00
Aaron Piotrowski
3f2e6d7f07
Drop custom exception constructors
2018-10-24 22:49:01 -05:00
Aaron Piotrowski
87d728ea35
Fix argument order
...
Oddly PhpStorm didn't highlight this as wrong.
2018-10-24 22:35:27 -05:00
Aaron Piotrowski
fe293c09bb
Improve process communication error handling
2018-10-23 22:14:51 -05:00
Aaron Piotrowski
14def89bff
Improve error messages when unserializable data is used
2018-10-23 22:10:12 -05:00
Aaron Piotrowski
3c0baa4e43
Remove catch of ChannelException
...
This catch block may hide errors that the user makes. If the parent died, another exception will be generated and caught below when trying to send the ExitFailure object.
2018-10-23 21:28:24 -05:00
Aaron Piotrowski
fd6c531d87
Add eof check on STDIN
2018-10-23 21:26:26 -05:00
Aaron Piotrowski
fe4df13ab9
Forward stdout and stderr from worker to parent
...
Restores previous behavior of process contexts when used in a worker.
2018-10-23 10:11:16 -05:00
Aaron Piotrowski
f1b0a59b86
Final all the things!
2018-10-21 10:54:46 -05:00
Aaron Piotrowski
83cd550895
Remove method kept for BC in DefaultPool
...
Mark DefaultPool::pull() as private and entire class as final.
2018-10-21 10:42:55 -05:00
Aaron Piotrowski
0d85b5a149
supported() → isSupported()
2018-10-21 10:34:32 -05:00
Aaron Piotrowski
e72a50dc8d
Upgrade to latest amphp/process release
...
STDOUT and STDERR of a child process is no longer automatically piped to STDOUT and STDERR of the parent. Instead these streams are available on Context\Process for the user to determine how they should be handled.
2018-10-21 10:25:29 -05:00
Aaron Piotrowski
cb2aa9c59c
Use 127.0.0.1 instead of localhost
...
Avoids DNS lookup issues on Windows.
2018-10-21 10:09:28 -05:00
Aaron Piotrowski
8d60fdbb64
Trigger error in process runner before exiting
2018-10-21 10:03:26 -05:00
Aaron Piotrowski
bf08e2fdf4
Remove output buffering in child process; update require scoping
2018-10-15 00:15:56 -05:00
Aaron Piotrowski
fa864692e7
Read key in chunks
...
Not entirely sure if this is necessary given the expected length, but it doesn't hurt either.
2018-10-11 18:11:02 -05:00
Aaron Piotrowski
9db273d484
Unset key if process connect times out; update docblocks
2018-10-11 11:14:14 -05:00
Aaron Piotrowski
4cf26d4dfb
Authenticate worker when connecting to IPC
2018-10-10 18:31:34 -05:00
Aaron Piotrowski
9e40d3aa0c
Use TCP for IPC on Windows
2018-10-09 09:12:23 -05:00
Aaron Piotrowski
562ae6f68d
Remove AbstractWorker::cancel() and report worker as running on start
2018-10-08 12:27:18 -05:00
Aaron Piotrowski
5987d844c8
Kill pool if still running on destruct
2018-10-07 10:16:49 -05:00
Aaron Piotrowski
526916d13c
Ignore multiple shutdown() calls; remove cancel() param
2018-10-07 09:56:09 -05:00
Aaron Piotrowski
b654463339
Fix code style
2018-10-07 09:50:45 -05:00
Aaron Piotrowski
cb5ea736d4
Improve process IPC
...
Processes now use a shared server socket instead of stdin and stdout for IPC.
2018-10-07 09:31:35 -05:00
Aaron Piotrowski
ca051a0aa6
Fail queued tasks after shutdown is invoked
2018-10-07 09:23:42 -05:00
Aaron Piotrowski
d81b6fccd2
Fix circular reference in BasicEnvironment ( Fixes #56 )
2018-10-07 09:23:13 -05:00
Niklas Keller
7326946884
Symlink PHARs if they don't have a .phar extension
2018-03-21 15:37:51 +01:00
Niklas Keller
c1114188b6
Improve error messages
2018-03-21 13:49:52 +01:00
Aaron Piotrowski
ed3662172d
Added signal() and getPid() methods to Process
2018-03-14 18:51:13 -05:00
Markus Staab
dbdc7895ac
Fixed typo ( #42 )
2018-02-27 23:26:51 +01:00
Markus Staab
1d6330ffc7
Fixed typo ( #41 )
2018-02-27 20:02:22 +01:00
Chris Wright
11a3e27db5
Escape script path in Process command ( #38 )
2018-01-31 18:31:36 +01:00
Syed Irfaq R. ⚡️
d2b9c03318
Fixes #35 ( #36 )
2018-01-22 16:15:09 -06:00
Aaron Piotrowski
abaa1609fd
Improve error message for invalid channel data
2018-01-22 16:12:55 -06:00
Niklas Keller
d16da4611e
Fix usage inside PHARs
2018-01-22 15:03:31 +01:00
Aaron Piotrowski
0d40e6da98
Do not fclose socket or null thread ref; restore GC test
2017-12-27 12:36:28 -06:00
Aaron Piotrowski
0a474e18c0
Avoid cyclic references in threads
2017-12-26 23:16:44 -06:00
Aaron Piotrowski
feb54951cc
Simplify worker implementation
...
Most of the complexity in AbstractWorker was to support out-of-order task execution.
2017-12-26 10:02:43 -06:00
Niklas Keller
cfd33799d7
Avoid cyclic references, fixes amphp/parallel-functions#5
2017-12-26 10:02:43 -06:00
Aaron Piotrowski
21b1a29748
Shorten task failure messages
2017-12-13 23:03:42 -06:00
Aaron Piotrowski
b9a8108540
Add ability to specify environment class name when creating factory
2017-12-13 22:18:12 -06:00
Aaron Piotrowski
fc4c2a07b7
Shorten job IDs
2017-12-13 21:28:08 -06:00
Aaron Piotrowski
f4411805d6
Fail task with SerializationException; cancel worker if sending otherwise fails
2017-12-13 20:56:28 -06:00
Aaron Piotrowski
9e7d1e0801
Throw if sending task fails
2017-12-13 16:29:44 -06:00
Aaron Piotrowski
312aecf1ff
Remove Worker::start()
...
The context can automatically be started when a job is enqueued.
2017-12-13 14:14:31 -06:00
Aaron Piotrowski
2a09f82f39
Add more process tests; exclude scripts from coverage
2017-12-13 13:56:11 -06:00
Aaron Piotrowski
d89c9e3dee
Catch serialization failure in process runner
2017-12-13 10:31:43 -06:00
Aaron Piotrowski
cb87b1cd9a
Use default sizes as default values
2017-12-12 21:59:38 -06:00
Aaron Piotrowski
91314f13f6
Shorten message from uncaught context exceptions
2017-12-12 21:08:59 -06:00
Aaron Piotrowski
8decdceb5d
Reorder Process constructor params
...
Shifted $binary to the end as it should rarely be needed.
2017-12-12 21:06:11 -06:00
Aaron Piotrowski
4d99a9d968
spawn → run
2017-12-10 17:01:10 -06:00
Aaron Piotrowski
852f580915
Remove $this magic from Thread callback
...
Channel is now passed as the first argument.
2017-12-10 16:53:51 -06:00
Aaron Piotrowski
4d4841f449
Refactor Process to make writing child processes simple
2017-12-10 16:39:49 -06:00
Aaron Piotrowski
cb15de11ff
Catch StreamExceptions thrown when reading
...
try/catch should have been around call to read().
2017-12-10 13:54:11 -06:00
Aaron Piotrowski
8c8c3123cb
Fix ternary associativity
2017-12-08 17:36:19 -06:00
Aaron Piotrowski
4b8cb791c2
Start global pool on creation
2017-12-08 10:31:28 -06:00
Aaron Piotrowski
4426686e54
Reorganize
2017-12-07 21:26:55 -06:00
Aaron Piotrowski
1adb63d906
Remove do*() private methods
...
Replaced with Amp\call().
2017-12-07 20:49:44 -06:00
Aaron Piotrowski
11a115670c
Only modify binary path if null
...
Also remove setting process options, as this is done in amphp/process anyway.
2017-12-06 16:01:11 -06:00
Aaron Piotrowski
6be72c6754
Run tasks in-order
...
Tasks on Windows must be run in-order because STDIO pipes are blocking. IPC be refactored to use sockets in the future if desired.
2017-12-06 15:59:28 -06:00
Aaron Piotrowski
e3b1cfd0cf
Allow custom binary path or locate binary
2017-12-05 18:21:39 -06:00
Aaron Piotrowski
51b6421933
Simplify checking environment class name
2017-11-30 23:58:41 -06:00
Aaron Piotrowski
3f7f21875d
Exit if constructing channel fails.
2017-11-29 23:02:36 -06:00
Aaron Piotrowski
7bb49256be
Fix missed use statement
2017-11-29 17:58:00 -06:00
Aaron Piotrowski
d0a3001c6a
Fix a couple mistakes…
2017-11-29 15:07:00 -06:00
Aaron Piotrowski
599cbb8a82
Anonymous class → defined class
2017-11-29 15:05:15 -06:00
Aaron Piotrowski
3aff92fec4
Consolodate process and thread contexts into Context namespace
2017-11-29 15:01:32 -06:00
Aaron Piotrowski
33a5b89ff7
Refactor Parcels
2017-11-29 14:40:07 -06:00
Aaron Piotrowski
996654920d
Update for export of mutex and semaphore to amphp/sync
2017-11-29 14:12:28 -06:00
Aaron Piotrowski
48bbf75097
Locate autoloader file in thread
2017-11-25 09:04:00 -06:00
Aaron Piotrowski
e700395ac5
Better fix for #27
...
Assertions would crash the worker, this will return as a failed task.
2017-11-22 21:38:11 -06:00
Aaron Piotrowski
689de9a28b
Assert autoload of Task class did not fail
...
Fixes #27 .
2017-11-22 20:42:56 -06:00
Aaron Piotrowski
dbd3403087
Quiet style fixer
2017-11-10 11:35:47 -06:00
Aaron Piotrowski
26e826a05f
Add code to exception message, addresses #21
...
Code is no longer passed to exception constructor in parent context.
2017-11-10 11:32:15 -06:00
Aaron Piotrowski
0e71b18197
Faster freeing of task memory
2017-11-10 10:32:01 -06:00
Aaron Piotrowski
aaee76e3da
Rename Threading namespace to Thread
2017-11-10 10:00:04 -06:00
Aaron Piotrowski
f48066eb1b
Drop Fork along with Process and Strand interfaces
...
Forking is just too dangerous for virtually no gain over Process. Context now extends Sync\Channel.
2017-11-10 09:59:23 -06:00