-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Remove control queue #1210
Remove control queue #1210
Conversation
ipykernel/kernelbase.py
Outdated
async def dispatch_control(self, msg): | ||
# Ensure only one control message is processed at a time | ||
while self._block_control: | ||
await asyncio.sleep(0) |
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.
This looks like it could be implemented with an asyncio.Lock.
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.
Yes, that looks like a much more elegant approach.
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.
Done.
8ca6219
to
fc298e4
Compare
The tests pass for this except for the downstream |
991cd08
to
4fc40dc
Compare
self.control_stream.flush() | ||
|
||
socket = self.control_stream.socket | ||
while socket.poll(1): |
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.
This is blocking for 1ms, right? I think it should just check if there is a message:
while socket.poll(1): | |
while socket.poll(0): |
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.
I'd like to, but if I do that the ipyparallel
tests fail locally for me.
Co-authored-by: David Brochart <david.brochart@gmail.com>
b9f9e5c
to
6d69f30
Compare
To get
I don't know if these changes will be considered too aggressive too soon. |
Hmm, perhaps instead I can cut a version of jupyter_client 6.x that supports pyzmq 25? |
Or, perhaps we wait and fold this in to an ipykernel 7.x release with #1079? |
I see that #1079 still uses a queue for the control channel but it is no longer a Tornado queue of course. So this probably isn't needed after that, but the idea of simplifying by removing the queue might still be worth looking at. If #1079 is near merging then we should ignore this for now. But it looks like there is quite a lot of work to do for Windows and downstream projects? |
Sorry Ian if your work in this PR ends up not being merged, I was aware of #1079 of course but Steve picked it up recently and I don't know if it's close to being merged, although he seems to be progressing fast. |
No problem. This has been my first attempt at a substantial change to |
I had a go at the 6.x branch of jupyter_client, but I don't think it is revive-able. I think we can merge this and consider |
assert start > previous_end | ||
previous_end = end | ||
|
||
assert end >= start + timedelta(seconds=sleep) |
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.
This fails downstream in IPython with:
TypeError: '>=' not supported between instances of 'str' and 'datetime.datetime'
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.
These are the same symptoms that I observed at #1210 (comment). ipyparallel
unfortunately monkey-patches jupyter_clients conversion of strings to datetimes so it is a no-op, and some versions of pytest-asyncio
don't fully isolate the tests so sometimes some of these start and end dates come through as strings.
In this PR updating pytest-asyncio
to 0.23.5 worked, but this is evidently not sufficient as the IPython failure already uses pytest-asyncio-0.23.5
.
I think the sensible approach here is to assume that in this test sometimes, outside of our direct control, the dates are strings and convert them to datetimes. Otherwise this test is not testing what it is supposed to, it is testing the types of some fields returned in messages. I'll submit a PR here ASAP.
Currently when the control channel receives a message on the control stream, it puts it in a
tornado.queues.Queue
, and messages are popped off the queue one a time to be handled usingprocess_control
. I don't think the queue is necessary as the ZMQ socket/stream queues messages itself.This PR removes the control queue, simplifying the code. The functions
_flush_control_queue
andpoll_control_queue
are removed as there is no queue to flush or poll. I assume the latter is considered public by its naming convention, but I don't know if any downstream libraries will be relying on its existence.There are other queues used for the control channel and debugger that I have not looked at yet.
I have ensured that only one control message is handled at a time, to preserve the current behaviour. This uses a boolean flag in
dispatch_control
. This is a little strange as the use ofZMQStream.on_recv
allows us to concurrently handle multiple control messages that we then have to suppress. There is future work to be done here to perhaps use the ZMQ socket rather than the stream, and jupyter-server/jupyter_server#1362 and jupyter/jupyter_client#997 are relevant.