deephaven.execution_context

This module gives users the ability to directly manage the Deephaven query execution context on threads, which is critical for applications to correctly launch deferred query evaluations, such as table update operations in threads.

class ExecutionContext(j_exec_ctx)[source]

Bases: JObjectWrapper, ContextDecorator

An ExecutionContext represents a specific combination of query library, query compiler, and query scope under which a query is evaluated.

A default, systemic ExecutionContext is created when a Deephaven script session is initialized, and it is used to evaluate queries submitted through this script session. However, to be able to evaluate a query in a deferred manner, such as in a different thread from the script session thread, an application must explicitly obtain or build a ExecutionContext and use it as a context manager to enclose the query in the body of the with statement.

Note that, a ExecutionContext can be shared among many threads. The most typical use pattern would be to obtain the script session’s systemic ExecutionContext and use it to wrap a query run in a thread created by the user.

j_object_type

alias of ExecutionContext

get_exec_ctx()[source]

Returns the current thread’s ExecutionContext.

Return type:

ExecutionContext

Returns:

a ExecutionContext

make_user_exec_ctx(freeze_vars=None)[source]

Makes a new ExecutionContext based off the current thread’s ExecutionContext. The optional parameter freeze_vars should be a list of names in the current query scope. If it is provided, the resulting ExecutionContext will include a new query scope that is made up of only these names together with their current values. Future changes to the values of these names will not be visible in the new ExecutionContext.

Parameters:

freeze_vars (Union[str, Sequence[str]]) – the names of the vars in the current query scope to be frozen in the new one

Return type:

ExecutionContext

Returns:

a ExecutionContext

Raises:

DHError