NVIDIA Morpheus (24.10.01)
(Latest Version)

morpheus.utils.shared_process_pool.SharedProcessPool

class SharedProcessPool[source]

Bases: <a href="https://docs.python.org/3/library/functions.html#object">object</a>

Attributes
status
total_max_workers

Methods

<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.join">join</a>([timeout]) Wait until the SharedProcessPool is terminated.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.reset">reset</a>() Clear all the previous settings and restart the SharedProcessPool.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.set_usage">set_usage</a>(stage_name, percentage) Set the usage of the SharedProcessPool for a specific stage.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.start">start</a>() Start the SharedProcessPool that is currently stopped and keep the settings before last shutdown.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.stop">stop</a>() Stop receiving any new tasks.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.submit_task">submit_task</a>(stage_name, process_fn, *args, ...) Submit a task to the SharedProcessPool.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.terminate">terminate</a>() Terminate all processes and shutdown the SharedProcessPool immediately.
<a href="#morpheus.utils.shared_process_pool.SharedProcessPool.wait_until_ready">wait_until_ready</a>([timeout]) Wait until the SharedProcessPool is running and ready to accept tasks.
join(timeout=None)[source]

Wait until the SharedProcessPool is terminated.

Parameters
timeout_type_, optional

timeout in seconds to wait for the SharedProcessPool to be terminated, by default None. If None, it will wait indefinitely.

Raises
RuntimeError

If is called on a SharedProcessPool that is not stopped.

TimeoutError

If has been waiting more than the timeout.

reset()[source]

Clear all the previous settings and restart the SharedProcessPool.

Raises
RuntimeError

If the SharedProcessPool is not already shut down.

set_usage(stage_name, percentage)[source]

Set the usage of the SharedProcessPool for a specific stage.

Parameters
stage_namestr

The unique name of the stage.

percentagefloat

The percentage of the total workers that will be allocated to the stage, should be between 0 and 1.

Raises
RuntimeError

If the SharedProcessPool is not running.

ValueError

If the percentage is not between 0 and 1 or the total usage is greater than 1.

start()[source]

Start the SharedProcessPool that is currently stopped and keep the settings before last shutdown.

Raises
RuntimeError

If the SharedProcessPool is not shutdown.

stop()[source]

Stop receiving any new tasks.

submit_task(stage_name, process_fn, *args, **kwargs)[source]

Submit a task to the SharedProcessPool.

Parameters
stage_namestr

The unique name of the stage.

process_fnCallable

The function to be executed in the process pool.

argsAny

Arbitrary arguments for the process_fn.

kwargsAny

Arbitrary keyword arguments for the process_fn.

Returns
Task

The task object that includes the result of the process_fn.

Raises
RuntimeError

If the SharedProcessPool is not running.

ValueError

If the stage_name has not been set in the SharedProcessPool.

terminate()[source]

Terminate all processes and shutdown the SharedProcessPool immediately.

wait_until_ready(timeout=None)[source]

Wait until the SharedProcessPool is running and ready to accept tasks.

Parameters
timeout_type_, optional

timeout in seconds to wait for the SharedProcessPool to be ready, by default None. If None, it will wait indefinitely.

Raises
RuntimeError

If the SharedProcessPool is not initializing or running.

TimeoutError

If has been waiting more than the timeout.

Previous morpheus.utils.shared_process_pool.PoolStatus
Next morpheus.utils.shared_process_pool.SimpleFuture
© Copyright 2024, NVIDIA. Last updated on Dec 3, 2024.