Skip to content

loading spinner of pn.panel(..., defer_load=True) stops spinning when async function starts executing #4241

Open
@MarcSkovMadsen

Description

@MarcSkovMadsen

pn.panel==0.14.1

I'm digging more into async. I would like to be able to use Async to start my Panel app.

I believe it would be very natural that the content of your dashboard layout consists of some async functions. And that you show a loading_indicator while those functions are running.

What I see in practice though is that the loading spinner stops spinning when the function starts executing and not when it finishes.

2022-12-27-15-57-09

import asyncio
import time

import panel as pn

pn.extension()

def view():
    time.sleep(1)
    return "view"

def view2():
    time.sleep(1)
    return "view2"

async def view_async():
    await asyncio.sleep(1)
    return "view_async"

async def view_async2():
    await asyncio.sleep(1)
    return "view_async2"

pn.panel(view, defer_load=True).servable()
pn.panel(view_async, defer_load=True).servable()
pn.panel(view2, defer_load=True).servable()
pn.panel(view_async2, defer_load=True).servable()

Bonus

If the async functions could be scheduled such that the combined duration is 1 sec and not 1 sec + 1 sec that would also be great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions