Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Annoying message when interrupting python scripts

Reply
Thread Tools

Annoying message when interrupting python scripts

 
 
geoffbache
Guest
Posts: n/a
 
      06-17-2008
Hi all,

I find that I semi-frequently get the cryptic message

import site failed; use -v for traceback

printed on standard error when an arbitrary python script receives
SIGINT while the python interpreter
is still firing up. If I use -v for traceback I get something along
the lines of

'import site' failed; traceback:
Traceback (most recent call last):
File "/usr/lib/python2.4/site.py", line 61, in ?
import os
File "/usr/lib/python2.4/os.py", line 683, in ?
import copy_reg as _copy_reg
File "/usr/lib/python2.4/copy_reg.py", line 5, in ?
"""
KeyboardInterrupt

Is this a bug? I couldn't find any code, but I imagine something like
try:
import site
except:
sys.stderr.write("import site failed; use -v for traceback\n")

which should surely allow a KeyboardInterrupt exception through?

Regards,
Geoff Bache
 
Reply With Quote
 
 
 
 
geoffbache
Guest
Posts: n/a
 
      06-17-2008

To clarify: this is more serious than an incorrect error message, as
the intended interrupt gets swallowed and
script execution proceeds. Sometimes I seem to get half-imported
modules as well,
the script failing later with something like

AttributeError: 'module' object has no attribute 'getenv'

when trying to call os.getenv

Regards,
Geoff Bache
 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      06-17-2008
On Jun 18, 12:51 am, geoffbache <(E-Mail Removed)> wrote:
[snip]
> Is this a bug? I couldn't find any code, but I imagine something like
> try:
> import site
> except:
> sys.stderr.write("import site failed; use -v for traceback\n")
>
> which should surely allow a KeyboardInterrupt exception through?
>


Surely?? A bare "except" catches *all* remaining uncaught exceptions.
Allowing a KeyboardInterrupt exception through would require:
except KeyboardInterrupt:
pass
 
Reply With Quote
 
John Machin
Guest
Posts: n/a
 
      06-18-2008
On Jun 18, 12:26 pm, Ben Finney <(E-Mail Removed)>
wrote:
> John Machin <(E-Mail Removed)> writes:
> > On Jun 18, 12:51 am, geoffbache <(E-Mail Removed)> wrote:
> > [snip]
> > > Is this a bug? I couldn't find any code, but I imagine something like
> > > try:
> > > import site
> > > except:
> > > sys.stderr.write("import site failed; use -v for traceback\n")

>
> > > which should surely allow a KeyboardInterrupt exception through?

>
> > Surely?? A bare "except" catches *all* remaining uncaught exceptions.

>
> I parsed that "should" as "this should be changed".
>
> > Allowing a KeyboardInterrupt exception through would require:
> > except KeyboardInterrupt:
> > pass

>
> Actually, to allow it through would require re-raising it:
>
> except KeyboardInterrupt:
> raise
>
> Yes, I think that's what Geoff is saying "should" be done


And all of what he was saying or not saying or should have been saying
was prefaced by "I imagine" anyway
 
Reply With Quote
 
geoffbache
Guest
Posts: n/a
 
      06-18-2008

Ben is correct in his interpretation of what I'm trying to say. The
code "should surely be changed" so that it lets a KeyboardInterrupt
exception through.

Geoff
 
Reply With Quote
 
geoffbache
Guest
Posts: n/a
 
      06-19-2008

As nobody decried the idea of this being a bug, it now is

http://bugs.python.org/issue3137

/Geoff
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python Scripts with IIS - ASP or Python-based CGI scripts withIIS - which makes more sense? davidj411 Python 0 06-27-2008 04:38 PM
Interrupting a running python thread johan2sson@gmail.com Python 0 08-25-2006 10:25 PM
Stupid question: Making scripts python-scripts Jan Danielsson Python 8 07-22-2005 12:20 AM
Re: Stupid question: Making scripts python-scripts Jp Calderone Python 0 07-21-2005 02:38 PM
Annoying error message re running scripts....please help resolve Arawak Computer Support 2 02-04-2005 06:03 PM



Advertisments