unit_serve¶
A python task type as a process of the unit ABI simrun.unit/1.
python -m simrun.unit_serve <type> answers the messages of the protocol on its
standard input with the functions of the task type (plan, setup,
compute_unit, merge, and TaskType.units for count_units), one JSON message
per line on its standard output, its log on standard error: the implementation
python of a python plugin, which the harness runs as its carrier serve, so the
import of the plugin is paid once per process instead of once per unit. The
protocol is described in docs/unit-abi.md.
What the functions of a plugin print, and what the programs they start write to their standard output, goes to the standard error, the log: the standard output of the process carries the protocol alone.
answer
¶
The response to a request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_type
|
TaskType
|
The task type. |
required |
request
|
dict[str, Any]
|
The message of the host. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
serve
¶
Answer the messages of stdin on stdout until the end of stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_type
|
TaskType
|
The task type. |
required |
stdin
|
IO[str]
|
The messages of the host, one per line. |
required |
stdout
|
IO[str]
|
The responses, one per line. |
required |
protocol_stdout
¶
The standard output of the protocol, with the descriptor 1 the standard error.
The descriptor of the standard output is duplicated for the protocol, then
replaced by the standard error, and sys.stdout is the standard error: a print
of a plugin, a library writing to the descriptor 1 and a child process write
into the log, never between the messages.
Returns:
| Type | Description |
|---|---|
IO[str]
|
The stream of the protocol. |
main
¶
Serve the task type of the command line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
list[str] | None
|
The arguments, those of the command line without. |
None
|