[Idle-dev] module won't run in IDLE: puzzling traceback

Kurt B. Kaiser kbk at shore.net
Mon Jun 6 20:33:23 CEST 2005


Brian van den Broek <bvande at po-box.mcgill.ca> writes:

> I'm a hobbyist who posts mostly to Tutor; I'm doing my level best to 
> handle this "right". Apologies for any mis-steps. I have googled the 
> web and searched the gmane archive of this list for the terms 
> asyncqueue and putmessage but did not come up with anything that I 
> recognized as relevant.

Thanks!  You're definitely on the right track!

> The problem:
>
> I have a module which, when I run it with IDLE 1.1.1 produces the 
> following traceback:
>
> IDLE 1.1.1
>  >>> ================================ RESTART 
> ================================
>  >>>
> Traceback (most recent call last):
>    File "C:\PYTHON24\lib\idlelib\rpc.py", line 233, in asyncqueue
>      self.putmessage((seq, request))
>    File "C:\PYTHON24\lib\idlelib\rpc.py", line 333, in putmessage
>      raise IOError
> IOError

There was a socket error, or the socket no longer exists.  In other
words, the link to the subprocess failed while the IDLE GUI was trying
to pass the compiled code to the subprocess for execution.

> It leaves the program running (attempts to close the shell window 
> produce a "The program is still running!" dialog). My environment is 
> Python 2.4.1 running on a WindowsME box. Possibly of relevance: 1) I 
> run ZoneAlarm, 

Since this is fairly reproducible, try disconnecting from the web
for safety's sake, turn off ZoneAlarm, and see if the problem 
remains.  I suspect it will, but let's check.

> and 2) I often, but unpredictably, get the IDLE subprocess error
> message when attempting to relaunch IDLE after having shut it down,
> and have to kill a running Pythonw process in TaskManager to
> relaunch.

Windows, especially Windows ME, doesn't seem to always handle sockets
correctly when the GUI end of the socket goes away.  The subprocess
end should sense this, and that would cause IDLE's subprocess to exit.
If that doesn't happen, then when IDLE is started a conflict occurs.

I'm looking into adding "belt and suspenders" by sending an explicit
exit message to the subprocess before closing the socket from the
GUI end.

> My module runs fine when run via each of the following: a DOS
> console Python interpreter, PythonWin, DrPython, and SciTE. (When
> applicable, the each tool's 'Check Syntax' command passes just fine,
> and this includes the check in IDLE itself.)
>
> I have encountered this before with other modules of mine. I generally 
> use Leo (a pure Python literate programming outline style code editor 
> <http://webpages.charter.net/edreamleo/front.html>) to edit my longer 
> pieces of code. In the present case, and I believe in previous cases 
> of the same problem, I did indeed use Leo to write my code. Thus, I 
> cannot rule out that Leo is somehow implicated or at fault, but the 
> fact that other means of running my module work make me suspect it is 
> an IDLE issue, rather than a Leo one. (Previous cases of this problem 
> when running via IDLE also worked when ran via other means.)
>
> I realize that it would be helpful to have a minimal snippet 
> exhibiting the problem. But, I have been unable so far to produce a 
> small snippet. My original module is over 1200 loc, and I have spent 
> the better part of an hour trying to pare it down; I have reduced it 
> but it still stands at just under 750 loc. I am about to give up on 
> the attempt to pare it down further--at this point, removing any 
> docstrings, classes, methods, if blocks, or even print statements 
> cause the problem to disappear. (Indeed, I was only able to remove a 
> few classes, top-level statements, and all comments while preserving 
> the problem.)
>
> I have checked, and there are no tabs in my module and all lines end 
> with the Unix standard \n rather than the Windows \r\n. (I tried 
> converting to \r\n line endings, and it makes no difference.)
>
> I know nothing of IDLE's internals, and am not sufficiently skilled in 
> programming to acquire a meaningful understanding in a reasonable 
> time-frame. I would very much appreciate suggestions as to how to 
> narrow down the problem further.

I think the only way to get at this is to zip up your original module
and email it to me as an attachment.  I'll try to duplicate the
problem on Windows 2000.

In the meantime, you can run IDLE without the subprocess.
Unfortunately, with the new Windows installer it's no longer possible
to edit the IDLE launcher in the Start menu to use the -n switch.  I
guess I'll have to add an option in IDLE's configuration.

Meanwhile, simply open C:\Python24\Lib\idlelib\PyShell.py and at line
1272 change

use_subprocess = True

to

use_subprocess = False

Save PyShell.py, restart IDLE, and you will see a message in the shell
window that IDLE is now running without the subprocess.  This has
disadvantages (see the Tips section of Help / IDLE Help) but should
work for you until we get a handle on this.  Running w/o the
subprocess makes IDLE act more like the other GUIs you're using.

Alternatively, if you know how to create launchers on the Start menu,
you could create "IDLE NSP" which targets

c:\Python24\pythonw.exe  c:\Python24\Lib\idlelib\PyShell.py -n

-- 
KBK


More information about the IDLE-dev mailing list