-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
async support #323
async support #323
Conversation
The following restart and run all leads to a sql error when storing history
|
That also leads the the busy/idle indicator to be wrong. |
Got also this weird things which looks like killing the kernel:
|
I'm starting to be convinced that submitting cells should block submission of subsequent cells unless said otherwise i have the following:
Cell 1 is ran async, thus cell 2 execute immediately and raise an error |
Hi, @minrk. Trying to launch some async code in jupyter notebook. Running latest jupyter-notebook (5.5.0) with your version of ipykernel (run-async branch), getting this: What am I doing wrong? Update: A happy beta-tester so far :) |
@minrk, do you remember the discussion we had at scipy about execution messages being consumed while code is already running ? Could you give me some pointers on how to fix this ? I've also pushed some compatibility with IPython 7.0. |
I have a solution which I'm sure is wrong:
I'm going to assume the locks will of course not always be release in the order they've been taken right ? See also the new PR #11265 on IPython side that fix and document a couple of other things. |
One other thing I'd like to figure out when using IPykernel is how to run user code in other eventloops like trio and curio. Which so far I've managed to do this way, but block the tornado eventloop:
I've heard that trio has some asyncio integration support, so it would be nice to have better integration. |
Yes, it was to switch the message handler triggers from while True:
msg = await socket.recv_multipart()
await self.dispatch... This would require pyzmq >= 16 for asyncio support in Alternately, a smaller change could be to keep the async def on_recv(msg):
await self.msg_queue.put(msg)
async def process_queue():
while True:
msg = await self.msg_queue.get()
await self.dispatch(msg) This would have the slight possible downside that messages would be popped off the zmq queue into Python before they are handled. Not sure if that's a real issue, though. This pattern would give us the option to run the message handlers in an IO thread, since handoff could be threadsafe. This might be valuable if we want to switch runners.
I think we ought to be able to use the existing eventloop integration for qt, etc. to do this. That's where I would start. |
I've updated this to work with the latest iteration of ipython/ipython#11265 |
@Carreau I've re-added the queue and fixed some handling of ExecutionResult objects, and now it seems to work with my testing for asyncio and trio, at least. |
Thanks ! I'll have a look ok later. Hopping for an IPython 7.0 beta in the
next couple of weeks. Do we want to release IPykernel same time as IPython
? We could do a joint beta.
…On Tue, Sep 4, 2018, 17:28 Min RK ***@***.***> wrote:
@Carreau <https://github.com/Carreau> I've re-added the queue and fixed
some handling of ExecutionResult objects, and now it seems to work with my
testing for asyncio and trio, at least.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#323 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUez_4M4gWRnk61D-qo1HceHo2Xdthnks5uXpwngaJpZM4UMXqc>
.
|
Thanks I had a chance to look at the code. Should the aborts also flush the newly created queue instead of just looking at ZMQ ? I suppose that's what the current failure are from. |
ok, I think the last hurdle is dealing with eventloop integration and the message queue. Now that handling messages is async, we cannot allow the eventloop integration to work the way it does, witch pausing the main eventloop and pumping |
allow handlers to return anything acceptable to `gen.maybe_future` this should include tornado/asyncio coroutines and Futures
always use setuptools in setup
This reverts commit 12e19e3.
This now relies on ipython/ipython#11289 |
with async code, KeyboardInterrupt is raised in the main eventloop by default, which would halt the kernel. While running async code, register a special sigint handler that cancels the relevant task instead of halting the eventloop.
yaml doesn't like 4 spaces
which has different asyncio integration (specifically, not on asyncio by default)
it's only relevant on tornado 5 where asyncio is already running
not CancelledError, which is only for the true async runs
needed to get a later version
ipykernel/tests/test_async.py
Outdated
@pytest.mark.parametrize("asynclib", ["asyncio", "trio", "curio"]) | ||
@skip_without_async | ||
def test_async_interrupt(asynclib, request): | ||
asynclib = "asyncio" |
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.
TODO: remove I guess ?
The test failure seem to appear at the time of @takluyver's input transformer pr, more especially A bit tricky to bisect as one need to switch PTK version. It may be a miss-test, as I'm not sure why Payload on 6.0.0, where the
Payload on master:
|
Test was added pre big split, currently at commit 71fca97 (used to be ipython/ipython@e9db6d5), in PR ipython/ipython#4363, see issue ipython/ipython#1349 for background of why this was done, and why |
Also I've started to draft some Blog post (https://medium.com/@mbussonn/ipython-7-0-async-repl-a35ce050f7f7) still really early, and many parts to re-write, in particular if we want to make IPython/ipykernel release at the same time. |
The change in behavior of I'm not sure if this really make sens (@takluyver ?), I'm tempted to say that the |
Test of set_next input were testing not only that several set_next_input were not set several time; but was doing so via the side effect that `?` was triggering set_next_input. Use directly ip.set_next_input to not rely on the behavior or `?` which anyway is buggy
Meh, it's broken also on 6.4 and before in a different way, and only insert the current line, so InputTransformer2 behavior suits me. I've push a commit that fixes the test (test the actual behavior instead of testing via the fact that |
Test are now passing ! |
Change in set_next_input multi-call behavior seems fine to me, I'm happy with the updated test. Shall we land this and get ready to make prereleases? |
Sounds like a plan. There is a couple more PR in IPython I want to land.
Mostly the autoreload one, and matplotlib DISPLAY one, but I'd like for it
to be tested.
I'm just refrainig from making a release (of IPython) as apparently @ivanov
never made one, so I want to leave him the horror.
…On Mon, Sep 10, 2018, 10:56 Min RK ***@***.***> wrote:
Change in set_next_input multi-call behavior seems fine to me, I'm happy
with the updated test. Shall we land this and get ready to make prereleases?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#323 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUez-s4oDYz9jBl0lBjwb9t-X_8qJikks5uZilAgaJpZM4UMXqc>
.
|
OK! Landing this one, and we can make 5.0 beta to go with the IPython 7.0 beta |
Side, dumb question. Should we leapfrog 5.0 and 6.0 and do a 7.0 to sync the version number of IPython and IPykernel ? |
allow handlers to return anything acceptable to
gen.maybe_future
this should include tornado/asyncio coroutines and Futures
counterpart to ipython/ipython#11155
closes jupyter/notebook#3397