the python shell window is already executing a command

Terry Reedy tjreedy at udel.edu
Wed Sep 17 23:50:56 EDT 2014


On 9/17/2014 9:34 PM, Seymore4Head wrote:
> On Wed, 17 Sep 2014 18:56:47 -0400, Terry Reedy <tjreedy at udel.edu>

>> A little digging with Idle's grep (Find in Files) shows that the message
>> is produced by this code in idlelib/PyShell.py, about 825.
>>
>>      def display_executing_dialog(self):
>>          tkMessageBox.showerror(
>>              "Already executing",
>>              "The Python Shell window is already executing a command; "
>>              "please wait until it is finished.",
>>              master=self.tkconsole.text)
>>
>> This function is only called here (about line 735)
>>      def runcommand(self, code):
>>          "Run the code without invoking the debugger"
>>          # The code better not raise an exception!
>>          if self.tkconsole.executing:
>>              self.display_executing_dialog()
>>          <else run idle code in user process output view user>
>>
>> How is this run?  Run-Module F5 invokes
>> ScriptBinding.run_module_event(116) and thence _run_module_event (129).
>> This methods includes this.
>>          if PyShell.use_subprocess:
>>              interp.restart_subprocess(with_cwd=False)
>>
>> restart_subprocess includes these lines (starting at 470):
>>          # Kill subprocess, spawn a new one, accept connection.
>>          self.rpcclt.close()
>>          self.terminate_subprocess()
>>          console = self.tkconsole
>>          ...
>>          console.executing = False  # == self.tkconsole
>>          ...
>>          self.transfer_path(with_cwd=with_cwd)
>>
>> transfer_path calls runcommand but only after tkconsole.executing has
>> been set to False.  But this only happens if PyShell.use_subprocess is
>> True, which it normally is, but not if one starts Idle with the -n option.
>>
>> After conditionally calling interp.restart_subprocess, _run_module_event
>> directly calls interp.runcommand, which can fail when running with -n.
>> Are you?  This is the only way I know to get the error message.  Is so,
>> the second way to not get the error message is to not use -n and run
>> normally.
>
> Sorry.  I don't speak python yet.  Quite a few of the above terms are
> new to me.
>
> It may be that was trying to run the program again before the current
> one was finished.  In the past I was getting the error when I was
> (almost) sure the program had finished.  I will be more careful in the
> future, but I will also keep an eye out for the problem to repeat.
> I just tried to run the above program again and gave it more time to
> finish and I did not get the error, so it could well be I was jumping
> the gun.

My question was "How do you start Idle?"
(I can make a difference.)

-- 
Terry Jan Reedy




More information about the Python-list mailing list