jina.peapods.peas

class jina.peapods.peas.BasePea(args)[source]

Bases: object

BasePea is a thread/process- container of BaseRuntime. It leverages threading.Thread or multiprocessing.Process to manage the lifecycle of a BaseRuntime object in a robust way.

A BasePea must be equipped with a proper Runtime class to work.

runtime_cls: Type[BaseRuntime] = None
daemon

required here to set process/thread daemon

run()[source]

Method representing the BaseRuntime activity.

This method overrides run() in threading.Thread or multiprocesssing.Process.

Note

run() is running in subprocess/thread, the exception can not be propagated to the main process. Hence, please do not raise any exception here.

start()[source]

Start the Pea.

This method overrides start() in threading.Thread or multiprocesssing.Process.

wait_start_success()[source]

Block until all peas starts successfully.

If not success, it will raise an error hoping the outer function to catch it

close()[source]

Close the Pea

This method makes sure that the Process/thread is properly finished and its resources properly released

Return type

None

property role

Get the role of this pea in a pod

Return type

PeaRoleType