towhee.engine.operator_pool.OperatorPool

class towhee.engine.operator_pool.OperatorPool(cache_path: Optional[str] = None)[source]

Bases: object

OperatorPool manages Operator creation, acquisition, release, and garbage collection. Each TaskExecutor has one OperatorPool.

Methods

acquire_op

Instruct the OperatorPool to reserve and return the specified operator for use in the executor.

clear

release_op

Releases the specified operator and all associated resources back to the OperatorPool.

__init__(cache_path: Optional[str] = None)[source]
acquire_op(hub_op_id: str, op_args: Dict[str, any], tag: str) Operator[source]

Instruct the OperatorPool to reserve and return the specified operator for use in the executor.

Parameters:
  • hub_op_id – (str)

  • op_args – (Dict[str, any]) operator init parameters

Returns:

(towhee.operator.Operator)

The operator instance reserved for the caller.

release_op(op: Operator)[source]

Releases the specified operator and all associated resources back to the OperatorPool.

Parameters:

op – (towhee.Operator) Operator instance to add back into the operator pool.