-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add pending_requests
#227
base: main
Are you sure you want to change the base?
Add pending_requests
#227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to understand better, could you describe what you intend to write in a pending request?
"pending_requests": YArray[
YMap[
"id": str,
"type": str
]
]
Co-authored-by: David Brochart <[email protected]>
When user executes a long-running cell twice it could be: {
"pending_requests": [
{
# msg_id of an `shell.execute_request` (allowing to identify subsequent "iopub.status" by parent_header
"id": "3ec6186d-dbd2-486e-9622-e771b4bdcc21",
"type": "execute_request"
},
{
# if user scheduled two executions of the same cell we will need to wait until both are cleared
"id": "0acd4f22-e9cc-4dd1-969d-8aec793d987d",
"type": "execute_request"
}
]
} When user runs a cell with {
"pending_requests": [
{
# the request for execution of a cell with `input()`
"id": "6fd7fbd4-1c1d-4824-9c96-a57972b4be62",
"type": "execute_request"
},
{
# the response from the server
"id": "0acd4f22-e9cc-4dd1-969d-8aec793d987d",
"type": "input_request"
}
]
} Here is how an execution request and a subsequent And an execution followed by Here are some thoughts:
|
I'm not sure we should go down the road of allowing concurrent cell execution. Aren't executions queued anyway? |
This is not about concurrent executions but queuing. We need to record the queue to resolve the status properly. |
In #197 there is an |
To illustrate if I have a cell: from time import sleep
sleep(60) I execute it first time, the [
{
"id": "3ec6186d-dbd2-486e-9622-e771b4bdcc21",
"type": "execute_request"
}
] then while it is still running, say 5 seconds in, I execute it again; there are now two pending requests: [
{
"id": "3ec6186d-dbd2-486e-9622-e771b4bdcc21",
"type": "execute_request"
},
{
"id": "0acd4f22-e9cc-4dd1-969d-8aec793d987d",
"type": "execute_request"
}
] after another 55 seconds the first cell would finish and emit "idle" status; however, the cell should still display the "busy" status as there will be another 60 seconds until the second execution request completes and in the meantime the [
{
"id": "0acd4f22-e9cc-4dd1-969d-8aec793d987d",
"type": "execute_request"
}
] |
But if we don't process new execution requests until the cell's execution state is idle, we don't need to record pending executions? |
Good question. There are at least two use cases which cannot be resolved with simple
Currently, frontend records cell execution timing to cell metadata. If we only keep "status" flag there is no way for frontend to pick up the new message after reloading. Say I execute a cell twice with Similarly for input boxes, the frontend needs to know if the input request is still pending. If it does not know, it can get into a kernel deadlock state. Now, the current proposal is not ideal for the timing scenario either because if I run a cell with So maybe we should populate the cell execution timing metadata on the server. For reference, the timing code is here in JupyterLab. However, note, this is not only about setting the right timings, but also about notifying the extensions via a signal. Maybe it would be fine to populate metadata on server and in the scenario described earlier (a single cell executed twice with browser tab refreshed in the middle of the first execution) the frontend would watch to changes to that metadata field, and emit the signal respectively.
See above, but also I don't think we have any control on when the kernel processes the execution requests. We could do as you say (don't process next until previous returned idle), but I think that the messaging protocol says that queuing is handled by the kernel and it is its implementation detail; changing it to what you propose should not be a problem unless there is a substantial latency between server and kernel so maybe for remote kernels. |
I think this underlines the need to move to server-side execution. |
I can see that for plain text input, but password boxes would need special treatment ( |
We could imagine a special widget that would not show the password, but would still allow any client to enter it? |
A part of a proposed solution to jupyter-server/jupyter_server#990
Supersedes #197