mlos_bench.event_loop_context

EventLoopContext class definition.

Attributes

CoroReturnType

Type variable for the return type of an asyncio coroutine.

FutureReturnType

Type variable for the return type of a Future.

Classes

EventLoopContext

EventLoopContext encapsulates a background thread for asyncio

Module Contents

class mlos_bench.event_loop_context.EventLoopContext[source]

EventLoopContext encapsulates a background thread for asyncio event loop processing as an aid for context managers.

There is generally only expected to be one of these, either as a base class instance if it’s specific to that functionality or for the full mlos_bench process to support parallel trial runners, for instance.

It’s enter() and exit() routines are expected to be called from the caller’s context manager routines (e.g., __enter__ and __exit__).

enter() None[source]

Manages starting the background thread for event loop processing.

Return type:

None

exit() None[source]

Manages cleaning up the background thread for event loop processing.

Return type:

None

run_coroutine(coro: Coroutine[Any, Any, CoroReturnType]) FutureReturnType[source]

Runs the given coroutine in the background event loop thread and returns a Future that can be used to wait for the result.

Parameters:

coro (Coroutine[Any, Any, CoroReturnType]) – The coroutine to run.

Returns:

A future that will be completed when the coroutine completes.

Return type:

concurrent.futures.Future[CoroReturnType]

mlos_bench.event_loop_context.CoroReturnType[source]

Type variable for the return type of an asyncio coroutine.

mlos_bench.event_loop_context.FutureReturnType: TypeAlias = Future[CoroReturnType][source]

Type variable for the return type of a Future.