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

fix: pyodide interrupts #921

Merged
merged 4 commits into from
Mar 8, 2024
Merged

fix: pyodide interrupts #921

merged 4 commits into from
Mar 8, 2024

Conversation

akshayka
Copy link
Contributor

@akshayka akshayka commented Mar 8, 2024

This change gets interrupts working in WASM notebooks. The implementation uses SharedArrayBuffer, as recommended by Pyodide, which only works in secure contexts.

An example where interrupts now work:

while True:
  ...

For some reason, time.sleep() cannot be interrupted -- this tripped me up for a while, because I thought my interruption implementation was incorrect.

@akshayka akshayka requested a review from mscolnick March 8, 2024 00:25
Copy link

vercel bot commented Mar 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:28am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:28am

@@ -321,9 +315,9 @@ def launch_pyodide_kernel(
)

if is_edit_mode:
from marimo._output.formatters.formatters import register_formatters

register_formatters()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this just not needed before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to add this back, for both edit/run mode

@@ -18,7 +18,7 @@ import type {
export interface RawBridge {
put_control_request(operation: object): Promise<string>;
put_input(input: string): Promise<string>;
interrupt(): Promise<string>;
interrupt(buffer: Uint8Array): Promise<string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops yes

@akshayka akshayka merged commit bc4f1cc into main Mar 8, 2024
29 checks passed
@akshayka akshayka deleted the aka/fix-pyodide-interrupt branch March 8, 2024 01:53
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants