Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > What is the actual type of "interrupted system call"?

Reply
Thread Tools

What is the actual type of "interrupted system call"?

 
 
mrstevegross
Guest
Posts: n/a
 
      06-09-2009
I'm trying to write a try/catch block to handle an "interrupted system
call". However, I can't seem to locate information on the actual
typename of the exception. Does anyone know what it would be? I want
my code to look like this:

try:
...
except InterruptedSystemCall # what's the right name?
...


Thanks,
--Steve
 
Reply With Quote
 
 
 
 
Jean-Michel Pichavant
Guest
Posts: n/a
 
      06-09-2009
mrstevegross wrote:
> I'm trying to write a try/catch block to handle an "interrupted system
> call". However, I can't seem to locate information on the actual
> typename of the exception. Does anyone know what it would be? I want
> my code to look like this:
>
> try:
> ...
> except InterruptedSystemCall # what's the right name?
> ...
>
>
> Thanks,
> --Steve
>

pick up your choice:

exceptions.ArithmeticError exceptions.OSError
exceptions.UnicodeTranslateError
exceptions.AssertionError exceptions.OverflowError exceptions.UserWarning
exceptions.AttributeError exceptions.OverflowWarning exceptions.ValueError
exceptions.DeprecationWarning exceptions.PendingDeprecationWarning
exceptions.Warning
exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError
exceptions.EnvironmentError exceptions.RuntimeError exceptions.__class__
exceptions.Exception exceptions.RuntimeWarning exceptions.__delattr__
exceptions.FloatingPointError exceptions.StandardError exceptions.__dict__
exceptions.FutureWarning exceptions.StopIteration exceptions.__doc__
exceptions.IOError exceptions.SyntaxError exceptions.__getattribute__
exceptions.ImportError exceptions.SyntaxWarning exceptions.__hash__
exceptions.IndentationError exceptions.SystemError exceptions.__init__
exceptions.IndexError exceptions.SystemExit exceptions.__name__
exceptions.KeyError exceptions.TabError exceptions.__new__
exceptions.KeyboardInterrupt exceptions.TypeError exceptions.__reduce__
exceptions.LookupError exceptions.UnboundLocalError exceptions.__reduce_ex__
exceptions.MemoryError exceptions.UnicodeDecodeError exceptions.__repr__
exceptions.NameError exceptions.UnicodeEncodeError exceptions.__setattr__
exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__

CTRL+C (SIG_INT) is KeyboardInterrupt

Jean-Michel
 
Reply With Quote
 
 
 
 
mrstevegross
Guest
Posts: n/a
 
      06-09-2009
> exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError
>...
> exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__


Is there a single parent exception to all those? Or should I just
write it as:

try:
...
catch Exception:
...

Thanks,
--Steve
 
Reply With Quote
 
Jeff McNeil
Guest
Posts: n/a
 
      06-09-2009
On Jun 9, 2:22*pm, mrstevegross <(E-Mail Removed)> wrote:
> I'm trying to write a try/catch block to handle an "interrupted system
> call". However, I can't seem to locate information on the actual
> typename of the exception. Does anyone know what it would be? I want
> my code to look like this:
>
> try:
> * ...
> except InterruptedSystemCall # what's the right name?
> * ...
>
> Thanks,
> --Steve


You'll get that error when an async. event (signal) is delivered to
your application during a system call. It's a result of 'errno' being
set to errno.EINTR (4). I check for a few such specific conditions in
some of my code and I usually do it like so:

try:
.....
except EnvironmentError, e:
if e.errno == errno.EINTR:
do_something_with_eintr_error()
else:
raise

That works for me. There isn't an "InterruptedSystemCall" error or
equivalent in the standard exception hierarchy. EnvironmentError is
the parent of OSError & IOError, which is where you'll most likely be
encountering that state.

Thanks,

Jeff
mcjeff.blogspot.com
 
Reply With Quote
 
mrstevegross
Guest
Posts: n/a
 
      06-09-2009
> That works for me. *There isn't an "InterruptedSystemCall" error or
> equivalent in the standard exception hierarchy. *EnvironmentError is
> the parent of OSError & IOError, which is where you'll most likely be
> encountering that state.


Thanks!
--Steve
 
Reply With Quote
 
Jean-Michel Pichavant
Guest
Posts: n/a
 
      06-10-2009
mrstevegross wrote:
>> exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError
>> ...
>> exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__
>>

>
> Is there a single parent exception to all those? Or should I just
> write it as:
>
> try:
> ...
> catch Exception:
> ...
>
> Thanks,
> --Steve
>

You're right, Exception is the parent of (almost) all exceptions.
I wouldn't advise writing such block catching all exceptions, it makes
error tracking quite difficult. However if you don't know the type of
exception involved in a particular case, you can write

try:
....
except Exception, excInstance:
print excInstance.__class__.__name__
print excInstance.__dict__

If you know how to trigger the exception, it should print the class name
of the exception, along with its attributes. It will help you then write
a more focused except clause.

Jean-Michel


 
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
Unable to cast object of type 'System.Byte[]' to type 'System.String'. Imran Aziz ASP .Net 4 01-19-2011 03:39 AM
Type of actual ports is not compatible with type of ports of entity. mreister VHDL 1 05-25-2010 11:30 AM
Unable to cast object of type 'System.Web.UI.WebControls.SqlDataSource' to type 'System.Collections.IEnumerable'. Chris ASP .Net 1 02-12-2007 04:42 PM
Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'. jlecain@free.fr ASP .Net 0 08-03-2006 06:00 PM
Help: Unable to cast object of type 'System.Int32' to type 'System.String'. keithb ASP .Net 3 05-07-2006 08:06 AM



Advertisments