We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to make an async .watch example for the Panel basic tutorials.
async
.watch
It seems reactive expressions .watch does not support async functions.
import asyncio import concurrent.futures from time import sleep import panel as pn pn.extension() is_stopped=pn.rx(True) is_active = pn.rx(False) def name(stopped): if stopped: return "Start the wind turbine" else: return "Stop the wind turbine" rx_name = pn.rx(name)(is_stopped) submit = pn.widgets.Button(name=rx_name, disabled=is_active, loading=is_active) async def start_stop_wind_turbine(clicked): if not clicked: return is_active.rx.value=True with submit.param.update(loading=True, disabled=True): with concurrent.futures.ThreadPoolExecutor() as executor: future = executor.submit(sleep, 1) result = await asyncio.wrap_future(future) is_stopped.rx.value = not is_stopped.rx.value is_active.rx.value=False print("done") b_stop_wind_turbine = submit.rx.watch(start_stop_wind_turbine) pn.Column(submit, b_stop_wind_turbine, is_active).servable()
When I click the button I see
RuntimeWarning: coroutine 'start_stop_wind_turbine' was never awaited
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
I'm trying to make an
async
.watch
example for the Panel basic tutorials.It seems reactive expressions
.watch
does not support async functions.When I click the button I see
RuntimeWarning: coroutine 'start_stop_wind_turbine' was never awaited
The text was updated successfully, but these errors were encountered: