Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Two-process terminal frontend (ipython core branch) #864

Merged
merged 50 commits into from

5 participants

@ivanov
Owner

This PR supersedes @minrk's #708 (and in turn, @omazapa's #433)

It's not ready to merge yet, but I've fixed Min's complaint about ctrl-c crashing the kernel.

one thing i see currently wrong is when you invoke ipython zmq --existing ... - ctrl-c is broken and complains about not having a kernel (now fixed)

@fperez
Owner

Thanks for pounding on this one! BTW, I'd like to change the name of the client from zmq (which is just an internal implementation detail) to console, which better follows qtconsole, and is a more user-informative name.

@omazapa

thanks, great!!!

@takluyver
Owner

I think I'd given it the name zmqterminal at some point, to distinguish it from the standard single-process terminal interface. I don't know what's the best way to make that distinction clear.

@fperez
Owner

My reasoning was: ipython is the simple, one-process call, by historic precedent in terminal. And ipython <X> refers to all two process clients, for <X> equal to:

  • console: regular text console.
  • qtconsole: gui
  • notebook: web notebook right now.
  • other future ones: if they develop, we'll see.

But at least that gives a clear pattern that should be easy for users to understand/remember.

@ivanov
Owner

Progress report so far:

  1. refactored Qt-based Console and the terminal-based Console (which used to be called 'zmq') using one common mixin that both apps now utilize - both seem to work, though I need to do a more thorough job of flag and alias swallowing.
  2. renamed the ipython subcommand to 'console' - added some basic docs so it shows up in ipython --help and does the right thing for ipython console -h
  3. handle the interrupt handler for instances which started up with --existing flag in the same way as they're treated in qtconsole (print a message saying "Kernel process is either remote or unspecified. Cannot interrupt."
@minrk
Owner

awesome! I'll look through it later. For flags&aliases, I recommend looking at IPython.core.shellapp, and its two derivatives: IPKernelApp and TerminalIPythonApp. That mixin is actually less complete than what you put together, only defining the unique elements, and letting the descendants assemble the various components. I don't know which approach is better.

It would be great if you can split the swallow_args into just a function - it really should just be a single function with three args:

new_argv = strip_argv(argv, aliases=aliases, flags=flags)

since it's generically useful for any app that starts one or more others in a subprocess, but you want to be able to specify command-line args for both (e.g. I have designs on using it in ipcluster, so that some flags can be passed on to ipcontroller/ipengine).

I don't exactly know where that should go, though. Maybe utils.process?

IPython/frontend/kernelmixinapp.py
((186 lines not shown))
+ # make this stuff after this a function, in case the super stuff goes
+ # away. Also, Min notes that this functionality should be moved to a
+ # generic library of kernel stuff
+ self.swallow_args(app_aliases,app_flags,argv=argv)
+
+ def swallow_args(self, aliases,flags, argv=None):
+ if argv is None:
+ argv = sys.argv[1:]
+ self.kernel_argv = list(argv) # copy
+ # kernel should inherit default config file from frontend
+ self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name)
+ # Scrub frontend-specific flags
+ swallow_next = False
+ was_flag = False
+ # copy again, in case some aliases have the same name as a flag
+ # argv = list(self.kernel_argv)
@minrk Owner
minrk added a note

This second copy is a leftover from when there were two passes. This isn't necessary anymore.

(I know, I'm reviewing my own messy code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
IPython/frontend/kernelmixinapp.py
((96 lines not shown))
+
+
+ ssh = 'IPythonMixinConsoleApp.sshserver',
+)
+aliases.update(app_aliases)
+
+#-----------------------------------------------------------------------------
+# Classes
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# IPythonMixinConsole
+#-----------------------------------------------------------------------------
+
+
+class IPythonMixinConsoleApp(Configurable):
@minrk Owner
minrk added a note

minor thing - maybe call it ConsoleApp or KernelManagerApp? It's a Mixin for an application that starts/connects a KernelManager. For instance, InteractiveShellApp is relatively clear, because it affects apps that start an InteractiveShell (of any kind). Names are somewhat important, because they show up in config files. Our class/trait structure is our public configuration interface. This one is less important, because I don't think people will actually want to set any of these config values statically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@minrk
Owner

And if you could figure out how to cleanup connection files on sigint, that would be great. I think you are better at signal-handling than I am. The connection-file cleanup is handled in the KernelManager.__del__ method. The important thing is to not cleanup connection files that you didn't write.

@minrk
Owner

I'm pretty sure I've figured out the connection file cleanup, I'll push that shortly, unless you are working on it.

@minrk
Owner

okay, connection file cleanup is definitely better now. ctrl-C killed qtconsole will cleanup all of its files, and the terminal app will also get it done under normal circumstances. Obviously unclean shutdown (term) doesn't allow for cleanup.

@minrk
Owner

flags and aliases are working now, as well.

The main things that remain are:

  • a few renames
    • We need to make sure that the mixin's imports don't break tests or anything if zmq, etc. is not installed.
    • I'm not certain about the mixin class name. If it were to match the ShellApp, which is our mixin for applications that start an InteractiveShell, it would probably be KernelManagerApp, as it is a mixin for apps that start a KernelManager, but ConsoleApp may make more sense when it shows up in config.
    • frontend/terminal/zmqterminal -> frontend/terminal/console, if I understand our plans correctly
  • update docs, to take note of the new client
  • Figure out how to get the connection message from the kernel to not show up in the first prompt. Perhaps it should not be coming from the kernel, rather the frontend should print it, so that it can be managed properly. Otherwise, a time.sleep(1) is the only available answer.
  • add a way to kill the kernel. I don't know if you can bind keys to arbitrary python functions with readline, but if not, we need a frontend-only magic or something.
@minrk
Owner

Getting pretty close. I just fixed a few things regarding various message cases, signaling, startup, and unresponsive kernels, and moved the new code into frontend.terminal.console.

Another thing that needs to be done: port the multiline history changes in shell.interact, once #929 is merged.

I did have to fix two things outside the new code:

  • the heartbeat channel had various logical errors that come up when using the blockingKM, with its shorter poll (which I still had to lengthen to 1s)
  • zmqshell clobbered page.page at import, which meant that any frontends that import the class for config reference will be operating in a universe without a functional page command. This has been moved to shell instantiation.
@minrk
Owner

update on recent changes:

  • renames have been done (it is now IPython.frontend.consoleapp.IPythonConsoleApp)
  • connection message does not interfere with prompt

Still todo:

  • document new interface
  • kill kernel from frontend

after IRC discussion with @fperez, the idea is:

frontend magics can be accessed exclusively as %foo bar, and these should be checked by simple regexp in run_cell, to bypass relaying to the kernel.

For instance, this could be handled with %kernel kill / %kernel restart or similar.

Simple %kernel? should access a helpstring, but need not trigger full pinfo behavior.
Improvements affecting qtconsole or other code:

  • heartbeat logic fixed / improved
  • much more likely to cleanup connection files
  • swallow_argv is a standalone function
@fperez
Owner

Here's a quick stab at the right regexp for this:

import re

names = ['kernel', 'edit']
pattern = '^%(?P<name>' + '|'.join(names) + ') (?P<args>.*\S)\s+'
magic_re = re.compile(pattern)

line = '%kernel a1 a2  '

m = magic_re.match(line)
print 'pattern:', pattern
if m:
    print 'name:', m.group('name')
    print 'args:', m.group('args')

We'll also need to add the logic to catch ? and ??, but that should be about it.

@fperez
Owner

I fixed a couple of small problems arising from my renaming of lib.pylabtools, but I'm still getting an error in the test suite:

======================================================================
ERROR: Failure: ImportError (cannot import name ClientCompleter2p)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/frontend.py", line 33, in <module>
    from IPython.frontend.terminal.console.completer import ClientCompleter2p
ImportError: cannot import name ClientCompleter2p

----------------------------------------------------------------------

I looked at that file, and there's nothing named ClientCompleter2p in there, so I'm kind of puzzled as to what happened. A forgotten commit?

@fperez
Owner

In actual testing, I noticed that %debug isn't working right, b/c of what appears to be a buffering issue. If I issue a few l commands, nothing gets printed (though prompts do come out fine). Once I quit the debugger, all the buffered listings show up at once.

@minrk
Owner

@fperez - I think terminal.console.frontend is no longer used at all - that was the first draft, that didn't use InteractiveShell or anything.

I see that you pushed some changes to ipython/origin-termzmq. Did you mean to push them here?

@fperez
Owner
@minrk
Owner

I just did a rebase/push without issue. Also removed the unused frontend.py.

@fperez
Owner

Thanks! But I'm really puzzled, I tried again on a different machine and got the same set of errors:

(termzmq)amirbar[ipython]> git rebase master
First, rewinding head to replay your work on top of it...
Applying: basic kernelmanager and frontend wrote, support indentation but it dont run code yet
Applying: working in handlers
Applying: working in tab completion
Applying: completer not working fine
Applying: little bug fixed in kernelmanager's queues
Applying: raw_input captured and working fine
Applying: -mworking in tab-completion
Applying: tab completion is not working yet, unknow error
Applying: Make readline tab-completion work in two-process terminal frontend.
/home/fperez/ipython/ipython/.git/rebase-apply/patch:18: trailing whitespace.

warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
<stdin>:18: trailing whitespace.

warning: 1 line applied after fixing whitespace errors.
Falling back to patching base and 3-way merge...
fatal: Unable to create '/home/fperez/ipython/ipython/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Failed to merge in the changes.
Patch failed at 0009 Make readline tab-completion work in two-process terminal frontend.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

Furthermore, the above looks like a git bug: that index.lock file didn't exist before, I made sure to remove it... And even if I remove it again, it bombs even on --abort:

((d8c32bc...)|REBASE)amirbar[ipython]> git rebase --abort
fatal: Unable to create '/home/fperez/ipython/ipython/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
(termzmq)amirbar[ipython]> rm .git/ind

Very strange...

In any case, thanks! I'll keep a close eye on this version of git, in case it turns out I have to file a git bug report (for reference, it's git 1.7.5.4 from ubuntu 11.10).

Back to ipython...

The test suite almost passes, but I'm getting these really strange errors:

======================================================================
ERROR: Failure: ImportError (No module named IPython)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 71, in importFromDir
    fh, filename, desc = find_module(part, path)
ImportError: No module named IPython

======================================================================
ERROR: Failure: ImportError (No module named IPython)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 71, in importFromDir
    fh, filename, desc = find_module(part, path)
ImportError: No module named IPython

======================================================================
ERROR: Failure: ImportError (No module named IPython)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 71, in importFromDir
    fh, filename, desc = find_module(part, path)
ImportError: No module named IPython

======================================================================
ERROR: Failure: ImportError (No module named IPython)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/pymodules/python2.7/nose/importer.py", line 71, in importFromDir
    fh, filename, desc = find_module(part, path)
ImportError: No module named IPython

----------------------------------------------------------------------

Do you see those too? They're in iptest IPython.frontend.

@minrk
Owner

Ah, I used to see those - I don't know why they happen, but it seems like it tries to do something multithreaded, and can hit a race condition when rebasing many commits. I always git rebase -i now, and for some reason that seems to solve the issue.

As for iptest errors - no, I do not see any errors, the test suite passes just fine.

@fperez
Owner
@minrk
Owner

The %kernel frontend-magic stuff hasn't been implemented, but I've been thinking, and in my experience, most of the time that I want to kill the kernel, I want to do it when it's not responding, and a magic doesn't help.

Other than that, I can't think of anything else that jumped out.

@minrk
Owner

@fperez - raw_input/%debug should now be better behaved.

Do we want to block on the frontend-magics? Note that with the design we have proposed, the magics will only function if the frontend believes the kernel to be fully functional and waiting for input. That seems to completely eliminate the value of %kernel interrupt, and also means there's no difference between %kernel kill and os._exit(0) unless there is a bug in the frontend.

I don't think it's particularly useful to be able to signal the kernel only when it's perceived to be fully functional and responsive.

omazapa and others added some commits
@omazapa omazapa basic kernelmanager and frontend wrote, support indentation but it do…
…nt run code yet
295d085
@omazapa omazapa working in handlers 9a9fc06
@omazapa omazapa working in tab completion e1e6feb
@omazapa omazapa completer not working fine 447dc20
@omazapa omazapa little bug fixed in kernelmanager's queues 9d266d4
@omazapa omazapa raw_input captured and working fine 916cfd6
@omazapa omazapa -mworking in tab-completion 4182704
@omazapa omazapa tab completion is not working yet, unknow error 48461d3
@takluyver takluyver Make readline tab-completion work in two-process terminal frontend. 91df35a
@omazapa omazapa little bug fixed in pyout message print. fdbcb3d
@omazapa omazapa bug fixed prompt count using differents clients a7c91ab
@omazapa omazapa traceback support added 25d06b0
@omazapa omazapa bug fixed in prompt count after traceback 5f47482
@takluyver takluyver Replace tabs with spaces c9b58bd
@takluyver takluyver Separate out frontend.zmqterminal package. 2ebf9e3
@takluyver takluyver zmqterminal frontend now uses IPythonInputSplitter, and non-ascii cha…
…racters work.
b0e2b84
@takluyver takluyver Minor tidying up of zmqterminal.frontend 7b9b46e
@takluyver takluyver Minor tidy up of zmqterminal.completer 8d3b96f
@takluyver takluyver Refactor and simplification of zmqterminal. 1f9a029
@takluyver takluyver Simplify handling of messaging in zmqterminal. 2620844
@takluyver takluyver Nicer prompt formatting in zmqterminal, and use print_function. 6f1b48d
@minrk minrk rebased and updated to master abe8bd2
@minrk minrk zmqterminal subclasses TerminalInteractiveShell/IPApp
this does a lot of the boiler plate for us, so Omar's communication
code is used in place of run_cell / complete.

Now colors, prompts, indentation, cl-args, etc. are all inherited
from regular existing code.

keyboard interrupts don't work yet, the kernel just dies...
8360d3a
@minrk minrk protect execution_count from longs returned by json 129880a
@ivanov ivanov ignore KeyboardInterrupt until we can handle it fcf7cd5
@ivanov ivanov refactoring common code out of qtconsole 24cd16e
@ivanov ivanov zmqterminal now uses the zmq mixin app 2cecbf1
@ivanov ivanov restore KeyboardInterrupt capability c887ab9
@ivanov ivanov Out[] prompt now reflects updated execution_count 812a82f
@ivanov ivanov documentation update da159e1
@ivanov ivanov report inability to signal --existing kernels 31d0eac
@minrk minrk improve cleanup of connection files
* allow clean shutdown of qtconsole on sigint
* init_kernel_manager registers cleanup_connection_file with atexit
* connection_file trait is guaranteed to be abspath at end of init_connection_file(), so find methods are no longer necessary after this call.
* move cf removal from KM.__del__ to KM.cleanup_connection_file
* _new_connection_file only uses last segment of uuid, not the whole thing, which is ugly and overkill 2**48 is enough kernels.
b8f41d5
@minrk minrk update flags&aliases for two-process apps
swallow_args now appropriately removes only frontend-specific args,
and the apps parse front and backend args correctly
37a13a2
@minrk minrk Move IPython.frontend.zmqterminal to IPython.frontend.terminal.console fd34263
@minrk minrk ignore sigint during poll in kernel
Prevents KeyboardInterrupt caught in Kernel message under most
circumstances
796d78c
@minrk minrk Don't install payload-pager at the module-level in zmqshell
The payload pager should be installed at shell instantiation, otherwise
any code that might import zmqshell that is not itself a kernel, will have broken page.page.
9277d76
@minrk minrk Fixes to the heartbeat channel
* The heartbeat channel had some erroneous zeromq logic, and entirely False comments (as described in #967).  This has been fixed.

* KernelManager.is_alive() checks if the hb_channel is running if
the kernel is not owned, rather than always returning True.

* BlockingKM's hb_channel has been relaxed to 1s polling, because replies are not
reliably much faster than that.  There are occasional >0.5s outlier responses.
f7e44e6
@minrk minrk Adjustment to console signal-handling
Do not explicitly interrupt the kernel, because the subprocess
already gets the interrupt.  Once we properly prevent this, then
the interrupt can be restored.

Also, the KeyboardInterrupt is still raised if not executing, in order
to restore the prompt.

In ipkernel, the interrupt is ignored during poll, and restored after
the loop exits, to prevent it being swallowed in future code that
expects normal sigint behavior.
9a0989a
@minrk minrk two-process interactive shell progress
* execute payloads (e.g. page/pinfo output) are displayed and paged.
* aborted replies don't crash frontend.
* intermediate iopub is displayed as it comes
* wait for kernel to start before printing first prompt.
  This gets the right number on the first prompt, and also
  avoids the log output from being drawn after the first prompt.
* protect most of the interact block from keyboard interrupts,
  which could cause weird errors if ctrl-C was held for a while.
* separate restart/wait prompt when kernel dies.
7431cd6
@minrk minrk bring multiline-hist fix from trunk into zmq console ca12bca
@minrk minrk rename IPythonMixinConsoleApp to IPythonConsoleApp
this will make itself more friendly to cofig
a345811
@minrk minrk don't use private TestCase._exc_info() method in parametric test
In Python 2.6, the method is one line, returning sys.exc_info(), and has been removed in Python 2.7.
d133113
@minrk minrk Split swallow_argv into standalone function in lib.kernel
adds frontend_flags/aliases traits to ConsoleApp derivatives for
use in this function.
5e833cd
@minrk minrk remove unused console/frontend.py ce04352
@minrk minrk [termconsole] raw_input improvements
* allow EOF to be forwarded
* flush iopub in more appropriate places
* handle interrupting raw_input better
67a9e3a
@fperez
Owner

Mmh, something broke here, I typed ipython console and I got a never-ending stream of these error messages:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/fperez/usr/lib/python2.7/site-packages/IPython/utils/ipstruct.py in __getattr__(self, key)
    149             result = self[key]
    150         except KeyError:
--> 151             raise AttributeError(key)
    152         else:
    153             return result

AttributeError: generate_prompt
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
UnboundLocalError: local variable 'prompt' referenced before assignment
---------------------------------------------------------------------------

Does the console work for you?

This tells me that we should, at the very least, add a test that starts a console, runs something simple, and shuts it down. We could do it using pexpect, actually...

@minrk
Owner

Of course, this was the first rebase since the PromptManager. Should be a quick fix.

@minrk
Owner

PromptManager issue fixed, I'll add a simple test.

@minrk
Owner

simple pexpect test added as well

@fperez
Owner

A few things:

  • prompt spacing is wrong, compare:
In [1]: import sys
In [2]: 'hello ipython'
Out[2]: 'hello ipython'
In [3]:

to

In [1]: import sys

In [2]: 'hello ipython'
Out[2]: 'hello ipython'

In [3]: 
  • plain exit doesn't cause an exit (which does work on the 2-process qt console).

  • Calling with --pylab causes crash:

Traceback (most recent call last):
  File "/home/fperez/usr/bin/ipython", line 7, in <module>
    launch_new_instance()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 403, in launch_new_instance
    app.start()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 373, in start
    return self.subapp.start()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 377, in start
    self.shell.mainloop()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/interactiveshell.py", line 205, in mainloop
    self.interact(display_banner=display_banner)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/interactiveshell.py", line 250, in interact
    if not self.wait_for_kernel(3):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/interactiveshell.py", line 220, in wait_for_kernel
    self.run_cell('1', False)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/interactiveshell.py", line 96, in run_cell
    self.handle_iopub()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/frontend/terminal/console/interactiveshell.py", line 145, in handle_iopub
    if self.session_id == sub_msg['parent_header']['session']:
KeyError: 'session'
@minrk
Owner

Interesting, because I see none of those issues. The KeyError I know is a bug that just doesn't happen to come up for me, but I'll fix it. However, it is strange that you have incorrect prompt spacing and exit doesn't work, when they behave perfectly for me. Do you have any related config?

@minrk
Owner

The KeyError should be fixed, but I don't know how to deal with the others since I can't reproduce them.

@fperez
Owner

Ok, that's truly bizarre: no special config, just tried by making a clean, fresh profile and running with that one. Still see all the above problems.

@fperez
Owner

Confirming that your last commit fixes the KeyError, now I can start with --pylab. I guess I'll have a crack at the others later on, gotta switch gears right now... You don't see them even on a linux box? I made sure to nuke all stale .pyc files, etc, so I'm surprised you're getting different behavior.

@minrk
Owner

I just tried it on Linux, and now I do see both. I wonder how they would be Linux-specific?

@fperez
Owner

Beats me, that's really odd. But at least it's not just little green men on my box :)

@minrk
Owner

No, I am somehow completely crazy. It's new since yesterday after the rebase, so I was using the old version. The prompt separation should be fixed now.

I don't know why exit would stop working. Any idea?

@fperez
Owner

Yup, prompts look fine now. No clue on the exit not working, b/c Control-D still does work, so our basic exiting machinery isn't really broken.

@minrk
Owner

I don't know how exit stopped being handled, but it should work now.

The main remaining issue is that the SIGINT catching machinery doesn't really work when a GUI is integrated (only affects owning frontend, not --existing).

@fperez
Owner

Well, everything is looking good enough to merge. In your question above about the magics, did you mean whether we should block merging this until we sort that out, or whether the frontend should block on frontend magics?

@minrk
Owner

The former - should we block merge

@fperez
Owner

I think we can merge now, and sort out what we want for %kernel later on. The earlier this goes in, the more chances we'll have of seeing any unintended ill side-effects.

Regarding %kernel, I think the main one would be %kernel restart, where one could get a fresh kernel without stopping the interactive session. Granted, it's a minimal difference to doing os._exit(); up-arrow-enter, but it may feel a little cleaner.

But precisely since it's small polish, let's worry about it post-merge. The rest of this is too useful and important not to have it in now.

I'm merging it; a huge thanks to you, @ivanov, @omazapa and everyone else who worked on this! @omazapa, you see how it took a long time but finally your work is in, and it will be part of the new 0.12 release :)

@fperez fperez merged commit afa2b63 into master
@fperez fperez referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 6, 2011
  1. @omazapa @minrk

    basic kernelmanager and frontend wrote, support indentation but it do…

    omazapa authored minrk committed
    …nt run code yet
  2. @omazapa @minrk

    working in handlers

    omazapa authored minrk committed
  3. @omazapa @minrk

    working in tab completion

    omazapa authored minrk committed
  4. @omazapa @minrk

    completer not working fine

    omazapa authored minrk committed
  5. @omazapa @minrk

    little bug fixed in kernelmanager's queues

    omazapa authored minrk committed
  6. @omazapa @minrk

    raw_input captured and working fine

    omazapa authored minrk committed
  7. @omazapa @minrk

    -mworking in tab-completion

    omazapa authored minrk committed
  8. @omazapa @minrk

    tab completion is not working yet, unknow error

    omazapa authored minrk committed
  9. @takluyver @minrk
  10. @omazapa @minrk

    little bug fixed in pyout message print.

    omazapa authored minrk committed
  11. @omazapa @minrk

    bug fixed prompt count using differents clients

    omazapa authored minrk committed
  12. @omazapa @minrk

    traceback support added

    omazapa authored minrk committed
  13. @omazapa @minrk

    bug fixed in prompt count after traceback

    omazapa authored minrk committed
  14. @takluyver @minrk

    Replace tabs with spaces

    takluyver authored minrk committed
  15. @takluyver @minrk

    Separate out frontend.zmqterminal package.

    takluyver authored minrk committed
  16. @takluyver @minrk

    zmqterminal frontend now uses IPythonInputSplitter, and non-ascii cha…

    takluyver authored minrk committed
    …racters work.
  17. @takluyver @minrk

    Minor tidying up of zmqterminal.frontend

    takluyver authored minrk committed
  18. @takluyver @minrk

    Minor tidy up of zmqterminal.completer

    takluyver authored minrk committed
  19. @takluyver @minrk

    Refactor and simplification of zmqterminal.

    takluyver authored minrk committed
  20. @takluyver @minrk

    Simplify handling of messaging in zmqterminal.

    takluyver authored minrk committed
  21. @takluyver @minrk
  22. @minrk

    rebased and updated to master

    minrk authored
  23. @minrk

    zmqterminal subclasses TerminalInteractiveShell/IPApp

    minrk authored
    this does a lot of the boiler plate for us, so Omar's communication
    code is used in place of run_cell / complete.
    
    Now colors, prompts, indentation, cl-args, etc. are all inherited
    from regular existing code.
    
    keyboard interrupts don't work yet, the kernel just dies...
  24. @minrk
  25. @ivanov @minrk

    ignore KeyboardInterrupt until we can handle it

    ivanov authored minrk committed
  26. @ivanov @minrk

    refactoring common code out of qtconsole

    ivanov authored minrk committed
  27. @ivanov @minrk

    zmqterminal now uses the zmq mixin app

    ivanov authored minrk committed
  28. @ivanov @minrk

    restore KeyboardInterrupt capability

    ivanov authored minrk committed
  29. @ivanov @minrk

    Out[] prompt now reflects updated execution_count

    ivanov authored minrk committed
  30. @ivanov @minrk

    documentation update

    ivanov authored minrk committed
  31. @ivanov @minrk

    report inability to signal --existing kernels

    ivanov authored minrk committed
  32. @minrk

    improve cleanup of connection files

    minrk authored
    * allow clean shutdown of qtconsole on sigint
    * init_kernel_manager registers cleanup_connection_file with atexit
    * connection_file trait is guaranteed to be abspath at end of init_connection_file(), so find methods are no longer necessary after this call.
    * move cf removal from KM.__del__ to KM.cleanup_connection_file
    * _new_connection_file only uses last segment of uuid, not the whole thing, which is ugly and overkill 2**48 is enough kernels.
  33. @minrk

    update flags&aliases for two-process apps

    minrk authored
    swallow_args now appropriately removes only frontend-specific args,
    and the apps parse front and backend args correctly
  34. @minrk
  35. @minrk

    ignore sigint during poll in kernel

    minrk authored
    Prevents KeyboardInterrupt caught in Kernel message under most
    circumstances
  36. @minrk

    Don't install payload-pager at the module-level in zmqshell

    minrk authored
    The payload pager should be installed at shell instantiation, otherwise
    any code that might import zmqshell that is not itself a kernel, will have broken page.page.
  37. @minrk

    Fixes to the heartbeat channel

    minrk authored
    * The heartbeat channel had some erroneous zeromq logic, and entirely False comments (as described in #967).  This has been fixed.
    
    * KernelManager.is_alive() checks if the hb_channel is running if
    the kernel is not owned, rather than always returning True.
    
    * BlockingKM's hb_channel has been relaxed to 1s polling, because replies are not
    reliably much faster than that.  There are occasional >0.5s outlier responses.
  38. @minrk

    Adjustment to console signal-handling

    minrk authored
    Do not explicitly interrupt the kernel, because the subprocess
    already gets the interrupt.  Once we properly prevent this, then
    the interrupt can be restored.
    
    Also, the KeyboardInterrupt is still raised if not executing, in order
    to restore the prompt.
    
    In ipkernel, the interrupt is ignored during poll, and restored after
    the loop exits, to prevent it being swallowed in future code that
    expects normal sigint behavior.
  39. @minrk

    two-process interactive shell progress

    minrk authored
    * execute payloads (e.g. page/pinfo output) are displayed and paged.
    * aborted replies don't crash frontend.
    * intermediate iopub is displayed as it comes
    * wait for kernel to start before printing first prompt.
      This gets the right number on the first prompt, and also
      avoids the log output from being drawn after the first prompt.
    * protect most of the interact block from keyboard interrupts,
      which could cause weird errors if ctrl-C was held for a while.
    * separate restart/wait prompt when kernel dies.
  40. @minrk
  41. @minrk

    rename IPythonMixinConsoleApp to IPythonConsoleApp

    minrk authored
    this will make itself more friendly to cofig
  42. @minrk

    don't use private TestCase._exc_info() method in parametric test

    minrk authored
    In Python 2.6, the method is one line, returning sys.exc_info(), and has been removed in Python 2.7.
  43. @minrk

    Split swallow_argv into standalone function in lib.kernel

    minrk authored
    adds frontend_flags/aliases traits to ConsoleApp derivatives for
    use in this function.
  44. @minrk
  45. @minrk

    [termconsole] raw_input improvements

    minrk authored
    * allow EOF to be forwarded
    * flush iopub in more appropriate places
    * handle interrupting raw_input better
  46. @minrk
  47. @minrk
  48. @minrk
  49. @minrk
  50. @minrk
Something went wrong with that request. Please try again.