module Procord_process:sig
..end
type 'a
process
val delegate : ('a, 'b) Procord_task.delegated_task -> 'a -> 'b process
Procord_worker.run
.
The task starts to run in the background immediately.
If command-line argument --procord-hostname
is empty, delegate
using Unix.create_process
, to the executable
Sys.executable_name
. Else, delegate using a socket connection
to a server worker (started with --procord-server) at the
address specified by --procord-hostname
, port
--procord-port
.
Call Procord_worker.run
at the beginning at your program if you plan
to use this function. Otherwise, use one of the alternatives below.
val delegate_task_create_process : ?stderr:Unix.file_descr ->
string ->
string array ->
('a, 'b) Procord_task.delegated_task -> 'a -> 'b process
Unix.create_process
.
The task starts to run in the background immediately.
Usage: delegate_task_create_process ?stderr program arguments task input
The program
is the executable file name. It can be the main
program file name itself (Sys.executable_name
), if it has a
way to distinguish whether it is a worker, for instance from
command-line arguments
.
stderr
: If specified, the created process will have its standard
error redirected to stderr
. If unspecified, everything the created
process writes on its standard error will be ignored.
Example: Unix.stderr
val delegate_task_socket : string ->
int ->
('a, 'b) Procord_task.delegated_task -> 'a -> 'b process
The socket is created immediately.
Usage: delegate_task_socket hostname port task input
The task will be delegated to a worker running on remote machine
hostname
, listening on port
.
The hostname
can be an IP address, an IPv6 address or a DNS address.
run_process
(which is blocking), or
call update
followed by process_status
regularly. Wait using
process_waiter
between two updates.type
execution_error =
| |
Worker_unknown_exception of |
(* | A worker raised an exception which was not handled by
write_exception . The string is obtained using Printexc . | *) |
| |
Worker_killed |
(* | You killed the worker yourself. | *) |
| |
Worker_disconnected of |
(* | An exception was raised while trying to connect to, send to, or receive from a worker; or the worker was killed, crashed or exited without returning any output; or there was an error while serializing an input value or deserializing an output value. | *) |
| |
No_worker_available of |
(* | No worker is available to perform the required task, or the selected worker cannot perform the required task. The string is the task name. | *) |
exception Execution_error of execution_error
val error_message : execution_error -> string
type 'a
status =
| |
Working |
(* | The task is not finished yet. | *) |
| |
Success of |
(* | The task was performed successfully, 'a is the result. | *) |
| |
Exception of |
(* | The task resulted in an exception that write_exception
could handle. | *) |
| |
Error of |
(* | Failed to execute the task. | *) |
val waiter : 'a process -> Procord_connection.waiter
val update : 'a process -> unit
process_status
.val status : 'a process -> 'a status
val run : 'a process -> 'a
Return the process return value or, if it raised an exception, raise this exception.
May also raise Execution_error
.
val kill : 'a process -> unit