Browse Source

Default exception handler no longer assumes all remaining exceptions take (errno, string) pairs.

Previously any exception that made it all the way up to the default
exception handler would be expected to take (errno, string) pairs,
as is the python standard for exceptions thrown by system calls.
All exceptions that don't take enough arguments throw a ValueError.

Based on the errno tested, it appears that this code
is meant to silently ignore when a socket receives a SIGINT (from
e.g. a timeout.)  This seems to be the only instance where handling
EINTR in this manner is desired - though having this bubble up this
far seems odd.

The existing code would also handle any other EINTR, though, which
includes those raised by OSError, WindowsError, and
anything that subclasses EnvironmentError, barring KeyboardError
because it is handled separately.  This is a bug as there is already
some use of the signals module elsewhere in CouchPotato.py to trap
SIGINT and SIGTERM outside of system calls, and most of these other
EINTRs should be handled by code lower down the stack.

A default exception handler is also added, so that unhandled
exceptions will be logged, and raised.
pull/89/head
Michael J. Cohen 13 years ago
parent
commit
ee4e91d318
  1. 14
      CouchPotato.py

14
CouchPotato.py

@ -4,6 +4,7 @@ from os.path import dirname
import logging
import os
import signal
import socket
import subprocess
import sys
import traceback
@ -121,9 +122,20 @@ if __name__ == '__main__':
pass
except SystemExit:
raise
except Exception as (nr, msg):
except socket.error as (nr, msg):
# log when socket receives SIGINT, but continue.
# previous code would have skipped over other types of IO errors too.
if nr != 4:
try:
l.log.critical(traceback.format_exc())
except:
print traceback.format_exc()
raise
except:
try:
# if this fails we will have two tracebacks
# one for failing to log, and one for the exception that got us here.
l.log.critical(traceback.format_exc())
except:
print traceback.format_exc()
raise
Loading…
Cancel
Save