towhee.runtime.operator_manager.operator_pool.OperatorPool

class towhee.runtime.operator_manager.operator_pool.OperatorPool[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__()[source]
acquire_op(key, hub_op_id: str, op_args: List, op_kws: Dict[str, any], tag: str) Operator[source]

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

Parameters:
  • key – (str)

  • hub_op_id – (str)

  • op_args – (List) Operator init parameters with args

  • op_kws – (Dict[str, any]) Operator init parameters with kwargs

  • tag – (str) The tag of operator

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.