mlos_bench.event_loop_context module

EventLoopContext class definition.

class mlos_bench.event_loop_context.EventLoopContext

Bases: object

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__).

Methods

enter()

Manages starting the background thread for event loop processing.

exit()

Manages cleaning up the background thread for event loop processing.

run_coroutine(coro)

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

enter() None

Manages starting the background thread for event loop processing.

exit() None

Manages cleaning up the background thread for event loop processing.

run_coroutine(coro: Coroutine[Any, Any, CoroReturnType]) Future[CoroReturnType]

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

Parameters:
coroCoroutine[Any, Any, CoroReturnType]

The coroutine to run.

Returns:
Future[CoroReturnType]

A future that will be completed when the coroutine completes.