jina.peapods.runtimes.zmq.asyncio module

class jina.peapods.runtimes.zmq.asyncio.AsyncNewLoopRuntime(args, cancel_event=None, **kwargs)[source]

Bases: jina.peapods.runtimes.base.BaseRuntime, abc.ABC

The async runtime to start a new event loop.

run_forever()[source]

Running method to block the main thread.

Run the event loop until a Future is done.

teardown()[source]

Call async_teardown() and stop and close the event loop.

async async_setup()[source]

The async method to setup.

async async_teardown()[source]

The async method to clean up resources during teardown. This method should free all resources allocated during async_setup

abstract async async_cancel()[source]

An async method to cancel async_run_forever.

abstract async async_run_forever()[source]

The async method to run until it is stopped.

static cancel(cancel_event, **kwargs)[source]

Signal the runtime to terminate :type cancel_event: Union[ForwardRef, ForwardRef] :param cancel_event: the cancel event to set :param kwargs: extra keyword arguments

static activate(**kwargs)[source]

Activate the runtime, does not apply to these runtimes

Parameters

kwargs – extra keyword arguments

static get_control_address(host, port, **kwargs)[source]

Get the control address for a runtime with a given host and port

Parameters
  • host (str) – the host where the runtime works

  • port (str) – the control port where the runtime listens

  • kwargs – extra keyword arguments

Returns

The corresponding control address

static wait_for_ready_or_shutdown(timeout, ready_or_shutdown_event, **kwargs)[source]

Check if the runtime has successfully started

Parameters
  • timeout (Optional[float]) – The time to wait before readiness or failure is determined

  • ready_or_shutdown_event (Union[ForwardRef, ForwardRef]) – the multiprocessing event to detect if the process failed or succeeded

  • kwargs – extra keyword arguments

Returns

True if is ready or it needs to be shutdown