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
Allow starting TerminalInteractiveShell more than once #9843
Conversation
1. always start with keep_running=True in `interact()` 2. don't close eventloop at end of mainloop (not sure this is the right thing to do)
it is possible for the completer to get reloaded/replaced, at which point the prompt-toolkit completions will not be those of ip.Completer, but whatever ip.Completer was originally.
@@ -12,8 +12,12 @@ | |||
|
|||
class IPythonPTCompleter(Completer): | |||
"""Adaptor to provide IPython completions to prompt_toolkit""" | |||
def __init__(self, ipy_completer): | |||
self.ipy_completer = ipy_completer | |||
def __init__(self, shell): |
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.
gruml gluml change of API.. gruml, gruml but I see the reason.
Can we check the type of shell and print a deprecation warning if it's a Completer ?
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.
Not every internal utility class is a public API, so I have no qualms changing this one. I can make it backward-compatible, though.
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.
Added now in a fully backward-compatible way, and explicitly declared the module as private APIs.
Probably, or should we have an event loop "reference counting" and a |
and declare that ptutils only contains private APIs
"""prompt-toolkit utilities | ||
|
||
Everything in this module is a private API, | ||
not to be used outside IPython. |
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.
Let's add it to the packages skipped for the API docs, in the list here.
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.
In fact, here.
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.
I don't think that quite works because it seems like the refcount would never be anything other than one after the class is instantiated, since the loop is setup in |
I've just had a look at the prompt_toolkit code, and it doesn't look like there should be any ill effects of not calling If we do call it anywhere, I think |
I tried putting it in |
There certainly are going to be circular references through |
Python 3.5 isn't recent enough, at least. |
I've just tested with a |
I did the same and it didn't (and again just now, with conda CPython 3.5.1 on OS X), so it's at least not a trustworthy event. Agreed on the other points, though. Thanks! |
keep_running=True
ininteract()
, which avoidsinteract()
being a no-op on all runs after the first.self
, notself.Completer
to PTCompleter, to ensure that it's always hooked up to shell.Completer, which can be replaced over time (pudb).cc @Carreau, @takluyver for the right thing to do about
_eventloop.close()
, since I doubt this is the right thing. Maybe register close withatexit.register
?cc @inducer this fixes inducer/pudb#193