Allow starting TerminalInteractiveShell more than once#9843
Allow starting TerminalInteractiveShell more than once#9843takluyver merged 5 commits intoipython:masterfrom
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.
IPython/terminal/ptutils.py
Outdated
| """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.
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.
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.
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.
Let's add it to the packages skipped for the API docs, in the list here.
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=Trueininteract(), which avoidsinteract()being a no-op on all runs after the first.self, notself.Completerto 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