MCPcopy Index your code
hub / github.com/ipython/ipython / cmdloop

Method cmdloop

IPython/terminal/debugger.py:104–148  ·  view source on GitHub ↗

Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. override the same methods from cmd.Cmd to provide prompt toolkit replacement.

(self, intro=None)

Source from the content-addressed store, hash-verified

102 return self.pt_app.prompt()
103
104 def cmdloop(self, intro=None):
105 """Repeatedly issue a prompt, accept input, parse an initial prefix
106 off the received input, and dispatch to action methods, passing them
107 the remainder of the line as argument.
108
109 override the same methods from cmd.Cmd to provide prompt toolkit replacement.
110 """
111 if not self.use_rawinput:
112 raise ValueError('Sorry ipdb does not support use_rawinput=False')
113
114 # In order to make sure that prompt, which uses asyncio doesn't
115 # interfere with applications in which it's used, we always run the
116 # prompt itself in a different thread (we can't start an event loop
117 # within an event loop). This new thread won't have any event loop
118 # running, and here we run our prompt-loop.
119 self.preloop()
120
121 try:
122 if intro is not None:
123 self.intro = intro
124 if self.intro:
125 print(self.intro, file=self.stdout)
126 stop = None
127 while not stop:
128 if self.cmdqueue:
129 line = self.cmdqueue.pop(0)
130 else:
131 self._ptcomp.ipy_completer.namespace = self.curframe_locals
132 self._ptcomp.ipy_completer.global_namespace = self.curframe.f_globals
133
134 # Run the prompt in a different thread.
135 if not _use_simple_prompt:
136 try:
137 line = self.thread_executor.submit(self._prompt).result()
138 except EOFError:
139 line = "EOF"
140 else:
141 line = input("ipdb> ")
142
143 line = self.precmd(line)
144 stop = self.onecmd(line)
145 stop = self.postcmd(stop, line)
146 self.postloop()
147 except Exception:
148 raise
149
150 def do_interact(self, arg):
151 ipshell = embed.InteractiveShellEmbed(

Callers

nothing calls this directly

Calls 4

inputFunction · 0.85
popMethod · 0.80
resultMethod · 0.80
precmdMethod · 0.80

Tested by

no test coverage detected