-
Notifications
You must be signed in to change notification settings - Fork 738
ThreadedHistory: invoke history load callback on event loop #1170
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
Conversation
Thanks for this! I'm looking into it. The test script is very helpful. I won't merge it yet because I'm looking into two things, which aren't obvious:
I would also like to make sure that multiple It's pretty complex to get the interaction between the history and the |
Hi Jonathan,
Could you point me at code samples where ptpython and ipython swap the
event loop? There's nothing magic about the event loop in this PR, perhaps
I can fix it to accommodate those scenarios.
Regards,
Bob
…On Sat, Aug 1, 2020, 2:10 PM Jonathan Slenders ***@***.***> wrote:
Thanks for this! I'm looking into it. The test script is very helpful.
I won't merge it yet because I'm looking into two things, which aren't
obvious:
- This breaks the loading of the history in ptpython (and I guess
IPython as well), where we swap out event loops for different event loops,
after the history class has been created.
- I want it to be possible for the history loading to be implemented
as an async generator (some kind of async stream to which buffers can
subscribe). The threaded loading should be build on top of that. It's a bit
complex, because the loading of the history entries happens on exactly the
opposite side of this stream from the new entries that are added by the
application user.
I would also like to make sure that multiple Buffer instances can share
the same History instance. I believe this has not been done so far, but
the code was somewhat written to make this possible.
It's pretty complex to get the interaction between the history and the
Buffer class completely correct and flexible enough for all use cases. I
don't want to rush into it and get this right before merging it. I hope to
have some time for it myself in the coming days/weeks.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1170 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPBIZBW6YBCXVSJ6RQKMPDR6SADZANCNFSM4ODRE4CA>
.
|
2abbf7d
to
548a99e
Compare
Installing this branch into my xonsh environment, I ran into a new error:
Perhaps it's unrelated, because I also updated xonsh at the same time. |
I've been using this patch for two weeks, it's solved the error and hasn't created any new ones, for me |
001e9a0
to
da6fc87
Compare
@jonathanslenders Please review now. |
da6fc87
to
546b578
Compare
Why has this not been merged yet? @bobhy perhaps it's an idea to just fork this and upload a new package to pypi, since jonathan seems to have been given up maintaining this repo for the last month |
I haven't given up. Just other priorities. Open source projects are not dead if there are a few months of inactivity. This PR is breaking ptpython, because the prompt runs in a different event loop. Actually with recent changes, the prompt even runs in a different thread. This is because we don't want the prompt to share the same loop with potential asyncio code running in the background. There are many challenges related to concurrency. See: https://github.com/prompt-toolkit/ptpython/blob/9900c8bb98262cffe9685c2fb9a7b7d07c2039dc/docs/concurrency-challenges.rst Most of it is working however. The problem is that the whole application can be created in one thread. (Like the A few other things:
Probably I hope to get some time for this in the coming days. |
Hi all, I have an improved implementation ready that I'm about to merge: #1328 Special thanks to @bobhy for the original history improvement proposal and script to reproduce the Xonsh bug. That has been proven very useful. In the end, I could not merge this PR, because it would break ptpython and possibly other tools, but I'm pretty satisfied with what I have right now. Thanks again to all for the patience! |
I can take a look at enabling the event loop swap out. I see how the legacy code does it now. Are you thinking about exposing an API for PTK to do this in a standard way? I could sketch one out as part of this... |
Hi @bobhy, thanks, but I think we're good now. I merged #1328 which seems to fix the issue, and has the requirements for the history API I had in mind. (to support async, like with the completions.) I did test with your test script from this PR, I tested with Xonsh, ptpython and IPython and all still seem to work well. So I went ahead and pushed prompt_toolkit 3.0.11 to PyPI. If you have some time, it would be great if you can test your Xonsh setup with the latest prompt_toolkit from PyPI now. |
Fixed in prompt_toolkit 3.0.14. |
Successor to #1159, but with a nice, compact commit history. Here is the original description:
Fixes issue #1158, and seems to work in Xonsh as well.
Depends on ThreadedHistory and Application being able to rendezvous on same event loop. While this may not be possible for history in general, I think it is an acceptable restriction on ThreadedHistory.