You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from Bender on #168:
We probably should make a hook just for submitting tasks with the execution context, similar to how I made the use_render_queue hook for submitting tasks on the render thread.
Could be named use_execution_context
The text was updated successfully, but these errors were encountered:
The hook can be used to call code within an execution context
It is a fairly niche hook, but here as an example of it being used to do
a table update on a separate thread
```
import deephaven.ui as ui
import threading
from deephaven.execution_context import get_exec_ctx
from deephaven import agg as agg
import deephaven.pandas as dhpd
import deephaven.plot.express as dx
stocks = dx.data.stocks()
def print_sym(source):
print(dhpd.to_pandas(source.update(["Symbol = sym"]) \
.agg_by([agg.avg(cols=["AVG = size"])], by=["Symbol"])))
@ui.component
def exec_ctx_hook(source):
with_exec_ctx = ui.use_execution_context()
def thread_func():
#print_sym(source)
with_exec_ctx(lambda: print_sym(source))
def start_thread():
thread = threading.Thread(target=thread_func)
thread.start()
ui.use_memo(start_thread, source)
return None
exec_hook = exec_ctx_hook(stocks)
```
Fixes#184
from Bender on #168:
We probably should make a hook just for submitting tasks with the execution context, similar to how I made the use_render_queue hook for submitting tasks on the render thread.
Could be named use_execution_context
The text was updated successfully, but these errors were encountered: