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
Panel: 0.12.1.
I've created this on the back of Discourse - Running async periodic callback
According to Panel - Async Functions, pn.state.add_periodic_callback can run async functions.
pn.state.add_periodic_callback
async
But if I try I get
C:\Users\masma\Anaconda3\envs\aw-lib\lib\site-packages\panel\io\callbacks.py:72: RuntimeWarning: coroutine 'test' was never awaited self.callback()
import panel as pn import asyncio pn.extension() text = pn.widgets.StaticText(value="test") async def test(): print("halo") text.value = "halo" await asyncio.sleep(1) text.value = "halo2" pn.state.add_periodic_callback(test, period=2000) pn.Row(text).servable()
According to tornadoweb/tornado#2828 (comment) I should use
pn.state.add_periodic_callback(lambda: asyncio.create_task(test()), period=2000)
import panel as pn import asyncio import datetime pn.extension() text = pn.widgets.StaticText(value="") async def test(): text.value = str(datetime.datetime.now()) + " start" await asyncio.sleep(1) text.value = str(datetime.datetime.now()) + " finish" pn.state.add_periodic_callback(lambda: asyncio.create_task(test()), period=2000) pn.Row(text).servable()
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Panel: 0.12.1.
I've created this on the back of Discourse - Running async periodic callback
According to Panel - Async Functions,
pn.state.add_periodic_callback
can runasync
functions.But if I try I get
Workaround
According to tornadoweb/tornado#2828 (comment) I should use
async.mp4
Solution
async
periodic callbacks.The text was updated successfully, but these errors were encountered: