accidentally catch KeyboardInterrupt.
return
try:
json = escape.json_decode(response.body)
- except:
+ except Exception:
logging.warning("Invalid JSON from Facebook: %r", response.body)
callback(None)
return
def _check_file(io_loop, modify_times, path):
try:
modified = os.stat(path).st_mtime
- except:
+ except Exception:
return
if path not in modify_times:
modify_times[path] = modified
for fd in io_loop._handlers.keys():
try:
os.close(fd)
- except:
+ except Exception:
pass
if hasattr(signal, "setitimer"):
# Clear the alarm signal set by
buffer=buffer, effective_url=effective_url, error=error,
request_time=time.time() - info["curl_start_time"],
time_info=time_info))
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
+ except Exception:
self.handle_callback_exception(info["callback"])
self._last_use_time = time.time()
try:
self.reconnect()
- except:
+ except Exception:
logging.error("Cannot connect to MySQL on %s", self.host,
exc_info=True)
# Python3 compatibility: On python2.5, introduce the bytes alias from 2.6
try: bytes
-except: bytes = str
+except Exception: bytes = str
try:
from urlparse import parse_qs # Python 2.6+
assert hasattr(json, "loads") and hasattr(json, "dumps")
_json_decode = json.loads
_json_encode = json.dumps
-except:
+except Exception:
try:
import simplejson
_json_decode = lambda s: simplejson.loads(_unicode(s))
stream = iostream.IOStream(connection, io_loop=self.io_loop)
HTTPConnection(stream, address, self.request_callback,
self.no_keep_alive, self.xheaders)
- except:
+ except Exception:
logging.error("Error in connection callback", exc_info=True)
class _BadRequestException(Exception):
fd, events = self._events.popitem()
try:
self._handlers[fd](fd, events)
- except (KeyboardInterrupt, SystemExit):
- raise
except (OSError, IOError), e:
if e.args[0] == errno.EPIPE:
# Happens when the client closes the connection
else:
logging.error("Exception in I/O handler for fd %d",
fd, exc_info=True)
- except:
+ except Exception:
logging.error("Exception in I/O handler for fd %d",
fd, exc_info=True)
# reset the stopped flag so another start/stop pair can be issued
def _run_callback(self, callback):
try:
callback()
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
+ except Exception:
self.handle_callback_exception(callback)
def handle_callback_exception(self, callback):
if not self._running: return
try:
self.callback()
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
+ except Exception:
logging.error("Error in periodic callback", exc_info=True)
if self._running:
self.start()
# Linux systems with our C module installed
import epoll
_poll = _EPoll
- except:
+ except Exception:
# All other systems
import sys
if "linux" in sys.platform:
if state != self._state:
self._state = state
self.io_loop.update_handler(self.socket.fileno(), self._state)
- except:
+ except Exception:
logging.error("Uncaught exception, closing connection.",
exc_info=True)
self.close()
def wrapper():
try:
callback(*args)
- except:
+ except Exception:
logging.error("Uncaught exception, closing connection.",
exc_info=True)
# Close the socket on an uncaught exception from a user callback
# For pretty log messages, if available
try:
import curses
-except:
+except ImportError:
curses = None
sum += datetime.timedelta(**{units: num})
start = m.end()
return sum
- except:
+ except Exception:
raise
def _parse_bool(self, value):
curses.setupterm()
if curses.tigetnum("colors") > 0:
color = True
- except:
+ except Exception:
pass
channel = logging.StreamHandler()
channel.setFormatter(_LogFormatter(color=color))
def die_on_error():
try:
yield
- except:
+ except Exception:
logging.error("exception in asynchronous operation",exc_info=True)
sys.exit(1)
try:
self.compiled = compile(self.code, "<template %s>" % self.name,
"exec")
- except:
+ except Exception:
formatted_code = _format_code(self.code).rstrip()
logging.error("%s code:\n%s", self.name, formatted_code)
raise
execute = namespace["_execute"]
try:
return execute()
- except:
+ except Exception:
formatted_code = _format_code(self.code).rstrip()
logging.error("%s code:\n%s", self.name, formatted_code)
raise
def _stack_context(self):
try:
yield
- except:
+ except Exception:
self.__failure = sys.exc_info()
self.stop()
raise self.failureException(
'Async operation timed out after %d seconds' %
timeout)
- except:
+ except Exception:
self.__failure = sys.exc_info()
self.stop()
self.io_loop.add_timeout(time.time() + timeout, timeout_func)
try:
self._cookies.load(
escape.native_str(self.request.headers["Cookie"]))
- except:
+ except Exception:
self.clear_all_cookies()
return self._cookies
logging.warning("Tampered cookie %r", value)
try:
return base64.b64decode(parts[0])
- except:
+ except Exception:
return None
def _cookie_signature(self, *parts):
f = open(abs_path, "rb")
hashes[abs_path] = hashlib.md5(f.read()).hexdigest()
f.close()
- except:
+ except Exception:
logging.error("Could not open static file %r", path)
hashes[abs_path] = None
base = self.request.protocol + "://" + self.request.host \
# so re-raise the exception to ensure that it's in
# sys.exc_info()
raise type, value, traceback
- except:
+ except Exception:
self._handle_request_exception(value)
return True