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

Perform async task before saving notebook #9764

Open
maartenbreddels opened this issue Feb 9, 2021 · 3 comments
Open

Perform async task before saving notebook #9764

maartenbreddels opened this issue Feb 9, 2021 · 3 comments

Comments

@maartenbreddels
Copy link
Contributor

Hi all,

I am trying to implement saving extra content in mime bundle in cell output on document saving in jupyter-widgets/ipywidgets#3107 . For this I was planning to use context.saveState.connect((sender, saveState) => ... but looking at

this._saveState.emit('started');
I see that the event is emitted, and not awaited for.

This makes it impossible to do async tasks before saving the document. I was wondering if this is a design decision or a possible oversight, or simply not implemented.

cheers,

Maarten

@jasongrout
Copy link
Contributor

I see that the event is emitted, and not awaited for.

You cannot await a signal emission: https://github.com/jupyterlab/lumino/blob/4f2432290e874b040310d428593abe4afc336066/packages/signaling/src/index.ts#L187-L189

@jasongrout
Copy link
Contributor

For reference (for others reading this), we hook into the signal to do synchronous tasks in ipywidgets around saving state: https://github.com/jupyter-widgets/ipywidgets/blob/c46e5dc306b7a908f749ede13392d8bdc5379821/jupyterlab_widgets/src/manager.ts#L524-L528

@maartenbreddels
Copy link
Contributor Author

That explains the _modelsSync and get_state_sync.

Do you think it is useful to have the option to perform async work before saving?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants