Updated TimeoutError and except Exception refs...

Updated eventlet.TimeoutError (deprecated) references to
Timeout and, more importantly, updated many except Exception
clauses to except (Exception, Timeout).

Change-Id: Ib089265551bd20b94c00ea84f11140ccd795d301
This commit is contained in:
gholt 2011-11-07 16:24:08 +00:00
parent 52ec042976
commit dd839048f1
24 changed files with 81 additions and 78 deletions

View File

@ -22,6 +22,8 @@ from swift.common.db import AccountBroker
from swift.common.utils import get_logger, audit_location_generator from swift.common.utils import get_logger, audit_location_generator
from swift.common.daemon import Daemon from swift.common.daemon import Daemon
from eventlet import Timeout
class AccountAuditor(Daemon): class AccountAuditor(Daemon):
"""Audit accounts.""" """Audit accounts."""
@ -98,7 +100,7 @@ class AccountAuditor(Daemon):
info = broker.get_info() info = broker.get_info()
self.account_passes += 1 self.account_passes += 1
self.logger.debug(_('Audit passed for %s') % broker.db_file) self.logger.debug(_('Audit passed for %s') % broker.db_file)
except Exception: except (Exception, Timeout):
self.account_failures += 1 self.account_failures += 1
self.logger.exception(_('ERROR Could not get account info %s'), self.logger.exception(_('ERROR Could not get account info %s'),
(broker.db_file)) (broker.db_file))

View File

@ -19,7 +19,7 @@ from logging import DEBUG
from math import sqrt from math import sqrt
from time import time from time import time
from eventlet import GreenPool, sleep from eventlet import GreenPool, sleep, Timeout
from swift.account.server import DATADIR from swift.account.server import DATADIR
from swift.common.db import AccountBroker from swift.common.db import AccountBroker
@ -233,12 +233,12 @@ class AccountReaper(Daemon):
self.container_pool.spawn(self.reap_container, account, self.container_pool.spawn(self.reap_container, account,
partition, nodes, container) partition, nodes, container)
self.container_pool.waitall() self.container_pool.waitall()
except Exception: except (Exception, Timeout):
self.logger.exception( self.logger.exception(
_('Exception with containers for account %s'), account) _('Exception with containers for account %s'), account)
marker = containers[-1][0] marker = containers[-1][0]
log = 'Completed pass on account %s' % account log = 'Completed pass on account %s' % account
except Exception: except (Exception, Timeout):
self.logger.exception( self.logger.exception(
_('Exception with account %s'), account) _('Exception with account %s'), account)
log = _('Incomplete pass on account %s') % account log = _('Incomplete pass on account %s') % account
@ -329,7 +329,7 @@ class AccountReaper(Daemon):
pool.spawn(self.reap_object, account, container, part, pool.spawn(self.reap_object, account, container, part,
nodes, obj['name']) nodes, obj['name'])
pool.waitall() pool.waitall()
except Exception: except (Exception, Timeout):
self.logger.exception(_('Exception with objects for container ' self.logger.exception(_('Exception with objects for container '
'%(container)s for account %(account)s'), '%(container)s for account %(account)s'),
{'container': container, 'account': account}) {'container': container, 'account': account})

View File

@ -21,6 +21,7 @@ import traceback
from urllib import unquote from urllib import unquote
from xml.sax import saxutils from xml.sax import saxutils
from eventlet import Timeout
from webob import Request, Response from webob import Request, Response
from webob.exc import HTTPAccepted, HTTPBadRequest, \ from webob.exc import HTTPAccepted, HTTPBadRequest, \
HTTPCreated, HTTPForbidden, HTTPInternalServerError, \ HTTPCreated, HTTPForbidden, HTTPInternalServerError, \
@ -312,7 +313,7 @@ class AccountController(object):
res = getattr(self, req.method)(req) res = getattr(self, req.method)(req)
else: else:
res = HTTPMethodNotAllowed() res = HTTPMethodNotAllowed()
except Exception: except (Exception, Timeout):
self.logger.exception(_('ERROR __call__ error with %(method)s' self.logger.exception(_('ERROR __call__ error with %(method)s'
' %(path)s '), {'method': req.method, 'path': req.path}) ' %(path)s '), {'method': req.method, 'path': req.path})
res = HTTPInternalServerError(body=traceback.format_exc()) res = HTTPInternalServerError(body=traceback.format_exc())

View File

@ -29,7 +29,7 @@ import errno
from random import randint from random import randint
from tempfile import mkstemp from tempfile import mkstemp
from eventlet import sleep from eventlet import sleep, Timeout
import simplejson as json import simplejson as json
import sqlite3 import sqlite3
@ -317,7 +317,7 @@ class DatabaseBroker(object):
except: except:
pass pass
self.possibly_quarantine(*sys.exc_info()) self.possibly_quarantine(*sys.exc_info())
except Exception: except (Exception, Timeout):
conn.close() conn.close()
raise raise
@ -336,13 +336,13 @@ class DatabaseBroker(object):
conn.execute('BEGIN IMMEDIATE') conn.execute('BEGIN IMMEDIATE')
try: try:
yield True yield True
except Exception: except (Exception, Timeout):
pass pass
try: try:
conn.execute('ROLLBACK') conn.execute('ROLLBACK')
conn.isolation_level = orig_isolation_level conn.isolation_level = orig_isolation_level
self.conn = conn self.conn = conn
except Exception: except (Exception, Timeout):
logging.exception( logging.exception(
_('Broker error trying to rollback locked connection')) _('Broker error trying to rollback locked connection'))
conn.close() conn.close()

View File

@ -23,7 +23,7 @@ import shutil
import uuid import uuid
import errno import errno
from eventlet import GreenPool, sleep, Timeout, TimeoutError from eventlet import GreenPool, sleep, Timeout
from eventlet.green import subprocess from eventlet.green import subprocess
import simplejson import simplejson
from webob import Response from webob import Response
@ -90,7 +90,7 @@ class ReplConnection(BufferedHTTPConnection):
response = self.getresponse() response = self.getresponse()
response.data = response.read() response.data = response.read()
return response return response
except Exception: except (Exception, Timeout):
self.logger.exception( self.logger.exception(
_('ERROR reading HTTP response from %s'), self.node) _('ERROR reading HTTP response from %s'), self.node)
return None return None
@ -331,7 +331,7 @@ class Replicator(Daemon):
broker.reclaim(time.time() - self.reclaim_age, broker.reclaim(time.time() - self.reclaim_age,
time.time() - (self.reclaim_age * 2)) time.time() - (self.reclaim_age * 2))
info = broker.get_replication_info() info = broker.get_replication_info()
except Exception, e: except (Exception, Timeout), e:
if 'no such table' in str(e): if 'no such table' in str(e):
self.logger.error(_('Quarantining DB %s'), object_file) self.logger.error(_('Quarantining DB %s'), object_file)
quarantine_db(broker.db_file, broker.db_type) quarantine_db(broker.db_file, broker.db_type)
@ -370,7 +370,7 @@ class Replicator(Daemon):
except DriveNotMounted: except DriveNotMounted:
repl_nodes.append(more_nodes.next()) repl_nodes.append(more_nodes.next())
self.logger.error(_('ERROR Remote drive not mounted %s'), node) self.logger.error(_('ERROR Remote drive not mounted %s'), node)
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR syncing %(file)s with node' self.logger.exception(_('ERROR syncing %(file)s with node'
' %(node)s'), {'file': object_file, 'node': node}) ' %(node)s'), {'file': object_file, 'node': node})
self.stats['success' if success else 'failure'] += 1 self.stats['success' if success else 'failure'] += 1
@ -443,7 +443,7 @@ class Replicator(Daemon):
while True: while True:
try: try:
self.run_once() self.run_once()
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR trying to replicate')) self.logger.exception(_('ERROR trying to replicate'))
sleep(self.run_pause) sleep(self.run_pause)
@ -487,7 +487,7 @@ class ReplicatorRpc(object):
timemark = time.time() timemark = time.time()
try: try:
info = broker.get_replication_info() info = broker.get_replication_info()
except Exception, e: except (Exception, Timeout), e:
if 'no such table' in str(e): if 'no such table' in str(e):
self.logger.error(_("Quarantining DB %s") % broker.db_file) self.logger.error(_("Quarantining DB %s") % broker.db_file)
quarantine_db(broker.db_file, broker.db_type) quarantine_db(broker.db_file, broker.db_type)

View File

@ -13,17 +13,17 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from eventlet import TimeoutError from eventlet import Timeout
class MessageTimeout(TimeoutError): class MessageTimeout(Timeout):
def __init__(self, seconds=None, msg=None): def __init__(self, seconds=None, msg=None):
TimeoutError.__init__(self, seconds=seconds) Timeout.__init__(self, seconds=seconds)
self.msg = msg self.msg = msg
def __str__(self): def __str__(self):
return '%s: %s' % (TimeoutError.__str__(self), self.msg) return '%s: %s' % (Timeout.__str__(self), self.msg)
class AuditException(Exception): class AuditException(Exception):
@ -42,15 +42,15 @@ class AuthException(Exception):
pass pass
class ChunkReadTimeout(TimeoutError): class ChunkReadTimeout(Timeout):
pass pass
class ChunkWriteTimeout(TimeoutError): class ChunkWriteTimeout(Timeout):
pass pass
class ConnectionTimeout(TimeoutError): class ConnectionTimeout(Timeout):
pass pass

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from eventlet import Timeout
from webob import Request from webob import Request
from webob.exc import HTTPServerError from webob.exc import HTTPServerError
import uuid import uuid
@ -44,7 +45,7 @@ class CatchErrorMiddleware(object):
response_headers.append(trans_header) response_headers.append(trans_header)
return start_response(status, response_headers, exc_info) return start_response(status, response_headers, exc_info)
return self.app(env, my_start_response) return self.app(env, my_start_response)
except Exception, err: except (Exception, Timeout), err:
self.logger.exception(_('Error: %s'), err) self.logger.exception(_('Error: %s'), err)
resp = HTTPServerError(request=Request(env), resp = HTTPServerError(request=Request(env),
body='An error occurred', body='An error occurred',

View File

@ -21,7 +21,7 @@ from hashlib import sha1
import hmac import hmac
import base64 import base64
from eventlet import TimeoutError from eventlet import Timeout
from webob import Response, Request from webob import Response, Request
from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \ from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
HTTPUnauthorized HTTPUnauthorized
@ -300,7 +300,7 @@ class TempAuth(object):
response = self.handle_request(req)(env, start_response) response = self.handle_request(req)(env, start_response)
self.posthooklogger(env, req) self.posthooklogger(env, req)
return response return response
except (Exception, TimeoutError): except (Exception, Timeout):
print "EXCEPTION IN handle: %s: %s" % (format_exc(), env) print "EXCEPTION IN handle: %s: %s" % (format_exc(), env)
start_response('500 Server Error', start_response('500 Server Error',
[('Content-Type', 'text/plain')]) [('Content-Type', 'text/plain')])

View File

@ -17,6 +17,8 @@ import os
import time import time
from random import random from random import random
from eventlet import Timeout
from swift.container import server as container_server from swift.container import server as container_server
from swift.common.db import ContainerBroker from swift.common.db import ContainerBroker
from swift.common.utils import get_logger, audit_location_generator from swift.common.utils import get_logger, audit_location_generator
@ -101,7 +103,7 @@ class ContainerAuditor(Daemon):
info = broker.get_info() info = broker.get_info()
self.container_passes += 1 self.container_passes += 1
self.logger.debug(_('Audit passed for %s'), broker.db_file) self.logger.debug(_('Audit passed for %s'), broker.db_file)
except Exception: except (Exception, Timeout):
self.container_failures += 1 self.container_failures += 1
self.logger.exception(_('ERROR Could not get container info %s'), self.logger.exception(_('ERROR Could not get container info %s'),
(broker.db_file)) (broker.db_file))

View File

@ -23,8 +23,7 @@ from xml.sax import saxutils
from datetime import datetime from datetime import datetime
import simplejson import simplejson
from eventlet.timeout import Timeout from eventlet import Timeout
from eventlet import TimeoutError
from webob import Request, Response from webob import Request, Response
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
HTTPCreated, HTTPInternalServerError, HTTPNoContent, \ HTTPCreated, HTTPInternalServerError, HTTPNoContent, \
@ -125,7 +124,7 @@ class ContainerController(object):
'device': account_device, 'device': account_device,
'status': account_response.status, 'status': account_response.status,
'reason': account_response.reason}) 'reason': account_response.reason})
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR account update failed with ' self.logger.exception(_('ERROR account update failed with '
'%(ip)s:%(port)s/%(device)s (will retry later)'), '%(ip)s:%(port)s/%(device)s (will retry later)'),
{'ip': account_ip, 'port': account_port, {'ip': account_ip, 'port': account_port,
@ -430,7 +429,7 @@ class ContainerController(object):
res = getattr(self, req.method)(req) res = getattr(self, req.method)(req)
else: else:
res = HTTPMethodNotAllowed() res = HTTPMethodNotAllowed()
except Exception: except (Exception, Timeout):
self.logger.exception(_('ERROR __call__ error with %(method)s' self.logger.exception(_('ERROR __call__ error with %(method)s'
' %(path)s '), {'method': req.method, 'path': req.path}) ' %(path)s '), {'method': req.method, 'path': req.path})
res = HTTPInternalServerError(body=traceback.format_exc()) res = HTTPInternalServerError(body=traceback.format_exc())

View File

@ -18,7 +18,7 @@ from time import ctime, time
from random import random, shuffle from random import random, shuffle
from struct import unpack_from from struct import unpack_from
from eventlet import sleep from eventlet import sleep, Timeout
from swift.container import server as container_server from swift.container import server as container_server
from swift.common.client import ClientException, delete_object, put_object, \ from swift.common.client import ClientException, delete_object, put_object, \
@ -322,7 +322,7 @@ class ContainerSync(Daemon):
sync_point1 = row['ROWID'] sync_point1 = row['ROWID']
broker.set_x_container_sync_points(sync_point1, None) broker.set_x_container_sync_points(sync_point1, None)
self.container_syncs += 1 self.container_syncs += 1
except Exception, err: except (Exception, Timeout), err:
self.container_failures += 1 self.container_failures += 1
self.logger.exception(_('ERROR Syncing %s'), (broker.db_file)) self.logger.exception(_('ERROR Syncing %s'), (broker.db_file))
@ -415,7 +415,7 @@ class ContainerSync(Daemon):
{'db_file': broker.db_file, 'row': row}) {'db_file': broker.db_file, 'row': row})
self.container_failures += 1 self.container_failures += 1
return False return False
except Exception, err: except (Exception, Timeout), err:
self.logger.exception( self.logger.exception(
_('ERROR Syncing %(db_file)s %(row)s'), _('ERROR Syncing %(db_file)s %(row)s'),
{'db_file': broker.db_file, 'row': row}) {'db_file': broker.db_file, 'row': row})

View File

@ -21,7 +21,7 @@ import time
from random import random, shuffle from random import random, shuffle
from tempfile import mkstemp from tempfile import mkstemp
from eventlet import spawn, patcher, Timeout, TimeoutError from eventlet import spawn, patcher, Timeout
from swift.container.server import DATADIR from swift.container.server import DATADIR
from swift.common.bufferedhttp import http_connect from swift.common.bufferedhttp import http_connect
@ -262,7 +262,7 @@ class ContainerUpdater(Daemon):
'X-Object-Count': count, 'X-Object-Count': count,
'X-Bytes-Used': bytes, 'X-Bytes-Used': bytes,
'X-Account-Override-Deleted': 'yes'}) 'X-Account-Override-Deleted': 'yes'})
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR account update failed with ' self.logger.exception(_('ERROR account update failed with '
'%(ip)s:%(port)s/%(device)s (will retry later): '), node) '%(ip)s:%(port)s/%(device)s (will retry later): '), node)
return 500 return 500
@ -271,7 +271,7 @@ class ContainerUpdater(Daemon):
resp = conn.getresponse() resp = conn.getresponse()
resp.read() resp.read()
return resp.status return resp.status
except (Exception, TimeoutError): except (Exception, Timeout):
if self.logger.getEffectiveLevel() <= logging.DEBUG: if self.logger.getEffectiveLevel() <= logging.DEBUG:
self.logger.exception( self.logger.exception(
_('Exception with %(ip)s:%(port)s/%(device)s'), node) _('Exception with %(ip)s:%(port)s/%(device)s'), node)

View File

@ -19,6 +19,9 @@ import uuid
import errno import errno
from hashlib import md5 from hashlib import md5
from random import random from random import random
from eventlet import Timeout
from swift.obj import server as object_server from swift.obj import server as object_server
from swift.obj.replicator import invalidate_hash from swift.obj.replicator import invalidate_hash
from swift.common.utils import get_logger, renamer, audit_location_generator, \ from swift.common.utils import get_logger, renamer, audit_location_generator, \
@ -128,7 +131,7 @@ class AuditorWorker(object):
return return
try: try:
name = object_server.read_metadata(path)['name'] name = object_server.read_metadata(path)['name']
except Exception, exc: except (Exception, Timeout), exc:
raise AuditException('Error when reading metadata: %s' % exc) raise AuditException('Error when reading metadata: %s' % exc)
_junk, account, container, obj = name.split('/', 3) _junk, account, container, obj = name.split('/', 3)
df = object_server.DiskFile(self.devices, device, partition, df = object_server.DiskFile(self.devices, device, partition,
@ -169,7 +172,7 @@ class AuditorWorker(object):
object_server.quarantine_renamer( object_server.quarantine_renamer(
os.path.join(self.devices, device), path) os.path.join(self.devices, device), path)
return return
except Exception: except (Exception, Timeout):
self.errors += 1 self.errors += 1
self.logger.exception(_('ERROR Trying to audit %s'), path) self.logger.exception(_('ERROR Trying to audit %s'), path)
return return

View File

@ -18,7 +18,7 @@ from sys import exc_info
from time import time from time import time
from urllib import quote from urllib import quote
from eventlet import sleep, TimeoutError from eventlet import sleep, Timeout
from paste.deploy import loadapp from paste.deploy import loadapp
from webob import Request from webob import Request
@ -99,20 +99,20 @@ class ObjectExpirer(Daemon):
self.delete_actual_object(actual_obj, timestamp) self.delete_actual_object(actual_obj, timestamp)
self.delete_object(container, obj) self.delete_object(container, obj)
self.report_objects += 1 self.report_objects += 1
except (Exception, TimeoutError), err: except (Exception, Timeout), err:
self.logger.exception( self.logger.exception(
_('Exception while deleting object %s %s %s') % _('Exception while deleting object %s %s %s') %
(container, obj, str(err))) (container, obj, str(err)))
self.report() self.report()
try: try:
self.delete_container(container) self.delete_container(container)
except (Exception, TimeoutError), err: except (Exception, Timeout), err:
self.logger.exception( self.logger.exception(
_('Exception while deleting container %s %s') % _('Exception while deleting container %s %s') %
(container, str(err))) (container, str(err)))
self.logger.debug(_('Run end')) self.logger.debug(_('Run end'))
self.report(final=True) self.report(final=True)
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('Unhandled exception')) self.logger.exception(_('Unhandled exception'))
def run_forever(self, *args, **kwargs): def run_forever(self, *args, **kwargs):
@ -129,7 +129,7 @@ class ObjectExpirer(Daemon):
begin = time() begin = time()
try: try:
self.run_once() self.run_once()
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('Unhandled exception')) self.logger.exception(_('Unhandled exception'))
elapsed = time() - begin elapsed = time() - begin
if elapsed < self.interval: if elapsed < self.interval:
@ -146,7 +146,7 @@ class ObjectExpirer(Daemon):
if resp.status_int in acceptable_statuses or \ if resp.status_int in acceptable_statuses or \
resp.status_int // 100 in acceptable_statuses: resp.status_int // 100 in acceptable_statuses:
return resp return resp
except (Exception, TimeoutError): except (Exception, Timeout):
exc_type, exc_value, exc_traceback = exc_info() exc_type, exc_value, exc_traceback = exc_info()
sleep(2 ** (attempt + 1)) sleep(2 ** (attempt + 1))
if resp: if resp:

View File

@ -588,7 +588,7 @@ class ObjectReplicator(Daemon):
try: try:
dump_recon_cache('object_replication_time', total, \ dump_recon_cache('object_replication_time', total, \
self.recon_object) self.recon_object)
except Exception: except (Exception, Timeout):
self.logger.exception(_('Exception dumping recon cache')) self.logger.exception(_('Exception dumping recon cache'))
def run_forever(self, *args, **kwargs): def run_forever(self, *args, **kwargs):
@ -606,7 +606,7 @@ class ObjectReplicator(Daemon):
try: try:
dump_recon_cache('object_replication_time', total, \ dump_recon_cache('object_replication_time', total, \
self.recon_object) self.recon_object)
except Exception: except (Exception, Timeout):
self.logger.exception(_('Exception dumping recon cache')) self.logger.exception(_('Exception dumping recon cache'))
self.logger.debug(_('Replication sleeping for %s seconds.'), self.logger.debug(_('Replication sleeping for %s seconds.'),
self.run_pause) self.run_pause)

View File

@ -33,7 +33,7 @@ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
HTTPNotModified, HTTPPreconditionFailed, \ HTTPNotModified, HTTPPreconditionFailed, \
HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed
from xattr import getxattr, setxattr from xattr import getxattr, setxattr
from eventlet import sleep, Timeout, TimeoutError, tpool from eventlet import sleep, Timeout, tpool
from swift.common.utils import mkdirs, normalize_timestamp, \ from swift.common.utils import mkdirs, normalize_timestamp, \
storage_directory, hash_path, renamer, fallocate, \ storage_directory, hash_path, renamer, fallocate, \
@ -222,7 +222,7 @@ class DiskFile(object):
try: try:
if verify_file: if verify_file:
self._handle_close_quarantine() self._handle_close_quarantine()
except Exception, e: except (Exception, Timeout), e:
import traceback import traceback
self.logger.error(_('ERROR DiskFile %(data_file)s in ' self.logger.error(_('ERROR DiskFile %(data_file)s in '
'%(data_dir)s close failure: %(exc)s : %(stack)'), '%(data_dir)s close failure: %(exc)s : %(stack)'),
@ -412,7 +412,7 @@ class ObjectController(object):
'response from %(ip)s:%(port)s/%(dev)s'), 'response from %(ip)s:%(port)s/%(dev)s'),
{'status': response.status, 'ip': ip, 'port': port, {'status': response.status, 'ip': ip, 'port': port,
'dev': contdevice}) 'dev': contdevice})
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR container update failed with ' self.logger.exception(_('ERROR container update failed with '
'%(ip)s:%(port)s/%(dev)s (saving for async update later)'), '%(ip)s:%(port)s/%(dev)s (saving for async update later)'),
{'ip': ip, 'port': port, 'dev': contdevice}) {'ip': ip, 'port': port, 'dev': contdevice})
@ -810,7 +810,7 @@ class ObjectController(object):
res = getattr(self, req.method)(req) res = getattr(self, req.method)(req)
else: else:
res = HTTPMethodNotAllowed() res = HTTPMethodNotAllowed()
except Exception: except (Exception, Timeout):
self.logger.exception(_('ERROR __call__ error with %(method)s' self.logger.exception(_('ERROR __call__ error with %(method)s'
' %(path)s '), {'method': req.method, 'path': req.path}) ' %(path)s '), {'method': req.method, 'path': req.path})
res = HTTPInternalServerError(body=traceback.format_exc()) res = HTTPInternalServerError(body=traceback.format_exc())

View File

@ -20,7 +20,7 @@ import sys
import time import time
from random import random from random import random
from eventlet import patcher, Timeout, TimeoutError from eventlet import patcher, Timeout
from swift.common.bufferedhttp import http_connect from swift.common.bufferedhttp import http_connect
from swift.common.exceptions import ConnectionTimeout from swift.common.exceptions import ConnectionTimeout
@ -214,7 +214,7 @@ class ObjectUpdater(Daemon):
resp = conn.getresponse() resp = conn.getresponse()
resp.read() resp.read()
return resp.status return resp.status
except (Exception, TimeoutError): except (Exception, Timeout):
self.logger.exception(_('ERROR with remote server ' self.logger.exception(_('ERROR with remote server '
'%(ip)s:%(port)s/%(device)s'), node) '%(ip)s:%(port)s/%(device)s'), node)
return 500 return 500

View File

@ -31,7 +31,7 @@ import functools
from hashlib import md5 from hashlib import md5
from random import shuffle from random import shuffle
from eventlet import sleep, GreenPile, Queue, TimeoutError from eventlet import sleep, GreenPile, Queue, Timeout
from eventlet.timeout import Timeout from eventlet.timeout import Timeout
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPMethodNotAllowed, \ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPMethodNotAllowed, \
HTTPNotFound, HTTPPreconditionFailed, \ HTTPNotFound, HTTPPreconditionFailed, \
@ -174,7 +174,7 @@ class SegmentedIterable(object):
self.segment_iter = resp.app_iter self.segment_iter = resp.app_iter
except StopIteration: except StopIteration:
raise raise
except Exception, err: except (Exception, Timeout), err:
if not getattr(err, 'swift_logged', False): if not getattr(err, 'swift_logged', False):
self.controller.app.logger.exception(_('ERROR: While ' self.controller.app.logger.exception(_('ERROR: While '
'processing manifest /%(acc)s/%(cont)s/%(obj)s'), 'processing manifest /%(acc)s/%(cont)s/%(obj)s'),
@ -207,7 +207,7 @@ class SegmentedIterable(object):
yield chunk yield chunk
except StopIteration: except StopIteration:
raise raise
except Exception, err: except (Exception, Timeout), err:
if not getattr(err, 'swift_logged', False): if not getattr(err, 'swift_logged', False):
self.controller.app.logger.exception(_('ERROR: While ' self.controller.app.logger.exception(_('ERROR: While '
'processing manifest /%(acc)s/%(cont)s/%(obj)s'), 'processing manifest /%(acc)s/%(cont)s/%(obj)s'),
@ -254,7 +254,7 @@ class SegmentedIterable(object):
yield chunk yield chunk
except StopIteration: except StopIteration:
raise raise
except Exception, err: except (Exception, Timeout), err:
if not getattr(err, 'swift_logged', False): if not getattr(err, 'swift_logged', False):
self.controller.app.logger.exception(_('ERROR: While ' self.controller.app.logger.exception(_('ERROR: While '
'processing manifest /%(acc)s/%(cont)s/%(obj)s'), 'processing manifest /%(acc)s/%(cont)s/%(obj)s'),
@ -385,7 +385,7 @@ class Controller(object):
attempts_left -= 1 attempts_left -= 1
if attempts_left <= 0: if attempts_left <= 0:
break break
except (Exception, TimeoutError): except (Exception, Timeout):
self.exception_occurred(node, _('Account'), self.exception_occurred(node, _('Account'),
_('Trying to get account info for %s') % path) _('Trying to get account info for %s') % path)
if result_code == 404 and autocreate: if result_code == 404 and autocreate:
@ -475,7 +475,7 @@ class Controller(object):
attempts_left -= 1 attempts_left -= 1
if attempts_left <= 0: if attempts_left <= 0:
break break
except (Exception, TimeoutError): except (Exception, Timeout):
self.exception_occurred(node, _('Container'), self.exception_occurred(node, _('Container'),
_('Trying to get container info for %s') % path) _('Trying to get container info for %s') % path)
if self.app.memcache and result_code in (200, 404): if self.app.memcache and result_code in (200, 404):
@ -626,7 +626,7 @@ class Controller(object):
query_string=req.query_string) query_string=req.query_string)
with Timeout(self.app.node_timeout): with Timeout(self.app.node_timeout):
possible_source = conn.getresponse() possible_source = conn.getresponse()
except (Exception, TimeoutError): except (Exception, Timeout):
self.exception_occurred(node, server_type, self.exception_occurred(node, server_type,
_('Trying to %(method)s %(path)s') % _('Trying to %(method)s %(path)s') %
{'method': req.method, 'path': req.path}) {'method': req.method, 'path': req.path})
@ -685,7 +685,7 @@ class Controller(object):
except GeneratorExit: except GeneratorExit:
res.client_disconnect = True res.client_disconnect = True
self.app.logger.warn(_('Client disconnected on read')) self.app.logger.warn(_('Client disconnected on read'))
except (Exception, TimeoutError): except (Exception, Timeout):
self.exception_occurred(node, _('Object'), self.exception_occurred(node, _('Object'),
_('Trying to read during GET of %s') % req.path) _('Trying to read during GET of %s') % req.path)
raise raise
@ -1173,7 +1173,7 @@ class ObjectController(Controller):
self.app.logger.warn( self.app.logger.warn(
_('ERROR Client read timeout (%ss)'), err.seconds) _('ERROR Client read timeout (%ss)'), err.seconds)
return HTTPRequestTimeout(request=req) return HTTPRequestTimeout(request=req)
except Exception: except (Exception, Timeout):
req.client_disconnect = True req.client_disconnect = True
self.app.logger.exception( self.app.logger.exception(
_('ERROR Exception causing client disconnect')) _('ERROR Exception causing client disconnect'))
@ -1201,7 +1201,7 @@ class ObjectController(Controller):
'body': bodies[-1][:1024], 'path': req.path}) 'body': bodies[-1][:1024], 'path': req.path})
elif 200 <= response.status < 300: elif 200 <= response.status < 300:
etags.add(response.getheader('etag').strip('"')) etags.add(response.getheader('etag').strip('"'))
except (Exception, TimeoutError): except (Exception, Timeout):
self.exception_occurred(conn.node, _('Object'), self.exception_occurred(conn.node, _('Object'),
_('Trying to get final status of PUT to %s') % req.path) _('Trying to get final status of PUT to %s') % req.path)
if len(etags) > 1: if len(etags) > 1:
@ -1663,7 +1663,7 @@ class BaseApplication(object):
response = self.handle_request(req)(env, start_response) response = self.handle_request(req)(env, start_response)
self.posthooklogger(env, req) self.posthooklogger(env, req)
return response return response
except Exception: except (Exception, Timeout):
print "EXCEPTION IN __call__: %s: %s" % \ print "EXCEPTION IN __call__: %s: %s" % \
(traceback.format_exc(), env) (traceback.format_exc(), env)
start_response('500 Server Error', start_response('500 Server Error',
@ -1733,7 +1733,7 @@ class BaseApplication(object):
if not getattr(handler, 'delay_denial', None): if not getattr(handler, 'delay_denial', None):
return resp return resp
return handler(req) return handler(req)
except Exception: except (Exception, Timeout):
self.logger.exception(_('ERROR Unhandled exception in request')) self.logger.exception(_('ERROR Unhandled exception in request'))
return HTTPServerError(request=req) return HTTPServerError(request=req)

View File

@ -15,8 +15,7 @@
import unittest import unittest
from eventlet import spawn, TimeoutError, listen from eventlet import spawn, Timeout, listen
from eventlet.timeout import Timeout
from swift.common import bufferedhttp from swift.common import bufferedhttp

View File

@ -33,7 +33,7 @@ from tempfile import TemporaryFile, NamedTemporaryFile
from eventlet import sleep from eventlet import sleep
from swift.common.exceptions import TimeoutError, MessageTimeout, \ from swift.common.exceptions import Timeout, MessageTimeout, \
ConnectionTimeout ConnectionTimeout
from swift.common import utils from swift.common import utils
@ -338,7 +338,7 @@ class TestUtils(unittest.TestCase):
def log_exception(exc): def log_exception(exc):
try: try:
raise exc raise exc
except (Exception, TimeoutError): except (Exception, Timeout):
logger.exception('blah') logger.exception('blah')
try: try:
# establish base case # establish base case

View File

@ -21,8 +21,7 @@ from StringIO import StringIO
from time import time from time import time
from tempfile import mkdtemp from tempfile import mkdtemp
from eventlet import spawn, TimeoutError, listen from eventlet import spawn, Timeout, listen
from eventlet.timeout import Timeout
import simplejson import simplejson
from webob import Request from webob import Request

View File

@ -21,8 +21,7 @@ from gzip import GzipFile
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
from eventlet import spawn, TimeoutError, listen from eventlet import spawn, Timeout, listen
from eventlet.timeout import Timeout
from swift.common import utils from swift.common import utils
from swift.container import updater as container_updater from swift.container import updater as container_updater

View File

@ -22,8 +22,7 @@ from shutil import rmtree
from time import time from time import time
from distutils.dir_util import mkpath from distutils.dir_util import mkpath
from eventlet import spawn, TimeoutError, listen from eventlet import spawn, Timeout, listen
from eventlet.timeout import Timeout
from swift.obj import updater as object_updater, server as object_server from swift.obj import updater as object_updater, server as object_server
from swift.obj.server import ASYNCDIR from swift.obj.server import ASYNCDIR

View File

@ -33,8 +33,7 @@ from hashlib import md5
from tempfile import mkdtemp from tempfile import mkdtemp
import eventlet import eventlet
from eventlet import sleep, spawn, TimeoutError, util, wsgi, listen from eventlet import sleep, spawn, Timeout, util, wsgi, listen
from eventlet.timeout import Timeout
import simplejson import simplejson
from webob import Request, Response from webob import Request, Response
from webob.exc import HTTPNotFound, HTTPUnauthorized from webob.exc import HTTPNotFound, HTTPUnauthorized
@ -166,7 +165,7 @@ def fake_http_connect(*code_iter, **kwargs):
if kwargs.get('raise_exc'): if kwargs.get('raise_exc'):
raise Exception('test') raise Exception('test')
if kwargs.get('raise_timeout_exc'): if kwargs.get('raise_timeout_exc'):
raise TimeoutError() raise Timeout()
return self return self
def getexpect(self): def getexpect(self):