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

Bug/Improvement: Correct handling of message sending #143

Closed
martenrichter opened this issue Nov 23, 2024 · 5 comments
Closed

Bug/Improvement: Correct handling of message sending #143

martenrichter opened this issue Nov 23, 2024 · 5 comments

Comments

@martenrichter
Copy link
Contributor

Recently a lot of bug reports regarding jupyter lite widget interactivity being broken:
#133
jupyterlite/jupyterlite#1465
jupyter-book/thebe#771
jupyter/try-jupyter#54

I have ran jupyter lite for two days in the debugger (see here my post about it here:
#133
).

And I am now relatively confident that the incomplete implementation of ``get_parentinkernel.py` and the js side:

is causing the trouble. As the control and shell channel parent is mixing through this simplification.
In contrast to:
https://github.com/ipython/ipykernel/blob/188f39c509f1056c3784aad6954498f31de955a3/ipykernel/kernelbase.py#L622

So I think that a patch for this behavior is required. And this may fix the issues. Do you agree?

Are you open for PR? (But I must say, I am very experienced in C++ and js (and a bit in ts), but not in python, but I think the changes do not require much understanding of the language details, so it is possible that I will give up, if I fail). Also I am not so sure how I can test the changes on pyodide-kernel alone. So input is appreciated.

P.S: I hope it is ok to open a separate issue, I thought in this way it is a bit more organized.

@martenrichter
Copy link
Contributor Author

Ok, I tried to implement it. But it was not the cause. Anyway, the wrong ordering of message with their kernel header is the cause. I also tried to reuse the parent headers from the initial execution attempt, but this did not work either (xeus has always the same parent msg_id, so I gave it a try). I will continue....

@martenrichter martenrichter changed the title Bug/Improvement: Correct handling of parent_headers Bug/Improvement: Correct handling of message_sending Nov 24, 2024
@martenrichter martenrichter changed the title Bug/Improvement: Correct handling of message_sending Bug/Improvement: Correct handling of message sending Nov 24, 2024
@martenrichter
Copy link
Contributor Author

Sorry for the erratic diagnosis posts. It has to something to do with the message sending order.
I have identified the problematic commit:
42e18ca

I would assume that replacing the post message changes the order or timing. I am sorry that I can not provide the exact cause. But for now, reverting the commit makes interactive widgets functional again.
So I recommend reverting it, and then merging a fixed change later.

@martenrichter
Copy link
Contributor Author

martenrichter commented Nov 24, 2024

[Delete was just the browser cache...]

@martenrichter
Copy link
Contributor Author

Additional things:
1.) Use test code:

%pip install -q ipywidgets
from ipywidgets import interact

# Function to handle text input
def display_text(value=''):
    return f"Updated value: {value}"

# Create an interactive Text widget
interact(display_text, value='Type something...');

Hit two keys on the keyboard simultaneously (I used for example g and h next to each other on my German keyboard), I can provoke the problem with 90% chance.
2.) I am not sure, if the message sending is really atomic in worker.ts. So are all transactions hidden in setup immediately or is there a message sending beneath it, when passing the parent header to python? THis may be the cause beneath the problem.

@martenrichter
Copy link
Contributor Author

Fixed by #148

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

No branches or pull requests

1 participant