Skip to content
New issue

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

Document how to instantiate shared instances asynchronously #4238

Closed
MarcSkovMadsen opened this issue Dec 26, 2022 · 2 comments
Closed

Document how to instantiate shared instances asynchronously #4238

MarcSkovMadsen opened this issue Dec 26, 2022 · 2 comments
Labels
type: docs Related to the Panel documentation and examples type: enhancement Minor feature or improvement to an existing feature

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Dec 26, 2022

I'm working on documenting how to use Dask with Panel including asynchronously.

I struggle figuring out what the best practice for instantiating shared objects asynchronously should be. The complication is that in a notebook you are running on an even loop and can just await in code cells. This you cannot in a server script - In a server script you can only await inside async functions.

I would like a request to describe the best practice for doing this in the Asynchronous Functions section of the user guide at https://panel.holoviz.org/user_guide/Async_and_Concurrency.html#asynchronous-functions.

The description should enable you to write code that works both in a notebook and a server app.

Example

The below code can run in a notebook but not in a server script.

import param

from dask.distributed import Client

CLIENT = await Client("tcp://127.0.0.1:64719", asynchronous=True)

class App():
    async def __init__(self):
        self._client = await Client("tcp://127.0.0.1:64719", asynchronous=True)

app = await App()
@MarcSkovMadsen MarcSkovMadsen added TRIAGE Default label for untriaged issues type: enhancement Minor feature or improvement to an existing feature type: docs Related to the Panel documentation and examples and removed TRIAGE Default label for untriaged issues labels Dec 26, 2022
@MarcSkovMadsen MarcSkovMadsen added this to the Wishlist milestone Dec 26, 2022
@MarcSkovMadsen
Copy link
Collaborator Author

Another example that I don't know how to do is

async def download_data(start_date=START_DATE, end_date=END_DATE):
    ...

await download_data()

@MarcSkovMadsen
Copy link
Collaborator Author

This has been solved by various improvements.

@philippjfr philippjfr removed this from the Wishlist milestone Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs Related to the Panel documentation and examples type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants