cobald.daemon.runners.base_runner module

class cobald.daemon.runners.base_runner.BaseRunner(asyncio_loop: AbstractEventLoop)[source]

Bases: object

Concurrency backend on top of asyncio

abstract async aclose()[source]

Shut down this runner

flavour = None
abstract async manage_payloads()[source]

Implementation of managing payloads when run()

This method must continuously execute payloads sent to the runner. It may only return when stop() is called or if any orphaned payload return or raise. In the latter case, OrphanedReturn or the raised exception must re-raised by this method.

async ready()[source]

Wait until the runner is ready to accept payloads

abstract register_payload(payload)[source]

Register payload for background execution in a threadsafe manner

This runs payload as an orphaned background task as soon as possible. It is an error for payload to return or raise anything without handling it.

async run()[source]

Execute all current and future payloads in an asyncio coroutine

This method will continuously execute payloads sent to the runner. It only returns when stop() is called or if any orphaned payload returns or raises. In the latter case, OrphanedReturn or the raised exception is re-raised by this method.

Implementations should override manage_payloads() to customize their specific parts.

abstract run_payload(payload)[source]

Execute payload and return its result in a threadsafe manner

This runs payload as soon as possible, blocking until completion. Should payload return or raise anything, it is propagated to the caller.

stop()[source]

Stop execution of all current and future payloads and block until success

exception cobald.daemon.runners.base_runner.OrphanedReturn(who, value)[source]

Bases: Exception

A runnable returned a value without anyone to receive it