%kill_embedded : deactivate for good the current embedded IPython This function (after asking for confirmation) sets an internal flag so that an embedded IPython will never activate again for the given call location. This is useful to permanently disable a shell that is bein
(self, parameter_s='')
| 40 | @magic_arguments.argument('-y', '--yes', action='store_true', |
| 41 | help='Do not ask confirmation') |
| 42 | def kill_embedded(self, parameter_s=''): |
| 43 | """%kill_embedded : deactivate for good the current embedded IPython |
| 44 | |
| 45 | This function (after asking for confirmation) sets an internal flag so |
| 46 | that an embedded IPython will never activate again for the given call |
| 47 | location. This is useful to permanently disable a shell that is being |
| 48 | called inside a loop: once you've figured out what you needed from it, |
| 49 | you may then kill it and the program will then continue to run without |
| 50 | the interactive shell interfering again. |
| 51 | |
| 52 | Kill Instance Option: |
| 53 | |
| 54 | If for some reasons you need to kill the location where the instance |
| 55 | is created and not called, for example if you create a single |
| 56 | instance in one place and debug in many locations, you can use the |
| 57 | ``--instance`` option to kill this specific instance. Like for the |
| 58 | ``call location`` killing an "instance" should work even if it is |
| 59 | recreated within a loop. |
| 60 | |
| 61 | .. note:: |
| 62 | |
| 63 | This was the default behavior before IPython 5.2 |
| 64 | |
| 65 | """ |
| 66 | |
| 67 | args = magic_arguments.parse_argstring(self.kill_embedded, parameter_s) |
| 68 | print(args) |
| 69 | if args.instance: |
| 70 | # let no ask |
| 71 | if not args.yes: |
| 72 | kill = ask_yes_no( |
| 73 | "Are you sure you want to kill this embedded instance? [y/N] ", 'n') |
| 74 | else: |
| 75 | kill = True |
| 76 | if kill: |
| 77 | self.shell._disable_init_location() |
| 78 | print("This embedded IPython instance will not reactivate anymore " |
| 79 | "once you exit.") |
| 80 | else: |
| 81 | if not args.yes: |
| 82 | kill = ask_yes_no( |
| 83 | "Are you sure you want to kill this embedded call_location? [y/N] ", 'n') |
| 84 | else: |
| 85 | kill = True |
| 86 | if kill: |
| 87 | self.shell.embedded_active = False |
| 88 | print("This embedded IPython call location will not reactivate anymore " |
| 89 | "once you exit.") |
| 90 | |
| 91 | if args.exit: |
| 92 | # Ask-exit does not really ask, it just set internals flags to exit |
| 93 | # on next loop. |
| 94 | self.shell.ask_exit() |
| 95 | |
| 96 | |
| 97 | @line_magic |
nothing calls this directly
no test coverage detected