[Idle-dev] IDLE Hung up after open script by command line

Tal Einat taleinat at gmail.com
Wed Sep 20 21:43:59 CEST 2006

Hi all, another WinXP SP2 user here.

First of all, this should be reproducible on any platform by running IDLE
with the "-n" flag.

On windows, the Python installer adds a "Edit with IDLE" context menu entry.
The OP mentioned that the problem only occurred when he opened the file in
this method and ran it with F5. Currently, the "Edit with IDLE" option opens
IDLE *without* a subprocess (with the "-n" flag), while the IDLE shortcut
runs IDLE *with* a subprocess (without the "-n" flag). In general it is much
better to run IDLE with a subprocess.

In this case what's happening is that the Python interpreter is constantly
busy, and (almost) never gets around to running IDLE. This is because IDLE
and the shell are actually running in the same process. On the other hand,
having IDLE and the shell run in separate processes allows IDLE to continue
functioning even while the shell is blocking or busy.

IDLE isn't broken, on the contrary! In IDLE the shell can be separated from
the GUI, which is a great feature, not found in most other Python

- Tal

P.S. The reason "Edit with IDLE" opens IDLE without a subprocess is that in
the current version there can only be one instance of IDLE with a
subprocess. I have submitted a patch to workaround this, and which allows
multiple version of IDLE to run in parallel, each with a subprocess of its
own. The patch must be more thoroughly tested and tweaked, but IMO is worth
giving a try.

On 9/19/06, Marek Nowicki <faramir2 at gazeta.pl> wrote:
> Hello,
> I wrote that code in python and saved as prx.py:
> --- CUT ---
> from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
> from time import strftime, gmtime
> import urllib2
> import thread
> from sys import stdout
> class RequestHandler(BaseHTTPRequestHandler):
>     def serve(self):
>         print "%s %s %s\r\n%s" % (self.command, self.path,
> self.request_version, self.headers)
>         header={}
>         header["content-length"]=0
>         for i in str(self.headers).split("\r\n"):
>             j=i.split(":", 1)
>             if len(j)==2:
>                 header[j[0].strip().lower()] = j[1].strip()
>         content=self.rfile.read(int(header["content-length"]))
>         print content
>         url="http://faramir2.prv.pl"
>         u=urllib2.urlopen(url)
>         for i,j in u.info().items():
>             print "%s: %s" % (i,j)
>         self.server_version = "Apache"
>         self.sys_version = ""
>         self.send_response(200)
>         self.send_header("Content-type", "text/html; charset=ISO-8859-2")
>         self.send_header("Connectin", "close")
>         self.end_headers()
>     def do_POST(self): self.serve()
>     def do_HEAD(self): self.serve()
>     def do_GET(self): self.serve()
> # from sys import exit
> # exit(1)
> address = ("", 80)
> server = HTTPServer(address, RequestHandler)
> thread.start_new_thread(server.serve_forever, () )
> --- CUT ---
> When I right click on that file and select "Edit with IDLE" it opens. Then
> when I push F5 the script is running. *Python Shell* is restarting. But
> when I try to connect by browser to http://localhost:80/ IDLE Hung-up. I
> don't see that hung ups when I open IDLE from shortcut and then in IDLE
> open file prx.py and run it works normally - good. IDLE does't hung up.
> I don't know why it works like that, but I think that it's bug..
> Python version: 2.5c2
> Tk version: 8.4
> IDLE version: 1.2c2
> regards,
> Marek
> _______________________________________________
> IDLE-dev mailing list
> IDLE-dev at python.org
> http://mail.python.org/mailman/listinfo/idle-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/idle-dev/attachments/20060920/f0974846/attachment.html 

More information about the IDLE-dev mailing list