Skip to main content

utils

SubprocessException

from dara.core.internal.pool.utils import SubprocessException

class SubprocessException()

Wraps the subprocess' exception. This is needed because by default traceback is not serialisable/picklable

Methods

unwrap

def unwrap()

Unwrap the exception with the serialised traceback

PicklingException

from dara.core.internal.pool.utils import PicklingException

class PicklingException(Exception)

Wraps any pickling errors so they can be distinguished from other errors

store_in_shared_memory

def store_in_shared_memory(content: Any) -> SharedMemoryPointer

Store content in shared memory

Returns a tuple of [shared_memory_name, shared_memory_size]

Arguments:

  • content: content to store in shared memory

read_from_shared_memory

def read_from_shared_memory(pointer: SharedMemoryPointer) -> Any

Read data from a named shared memory of given size

Arguments:

  • pointer: pointer to shared memory to read from

wait_while

async def wait_while(condition: Callable[[], bool],
timeout: Optional[float] = None)

Util to wait until a condition is False or timeout is exceeded

Arguments:

  • condition: function to call to check
  • timeout: optional time to wait until a TimeoutError is raised

stop_process_async

async def stop_process_async(process: BaseProcess, timeout: float = 3)

Attempt to stop a process

Does not block, waits for the process to terminate for a given number of seconds

Arguments:

  • process: process to stop
  • timeout: time to wait until the process is dead

stop_process

def stop_process(process: BaseProcess, timeout: float = 3)

Attempt to stop a process

Blocks with process.join()

Arguments:

  • process: process to stop
  • timeout: optional time to join the process for