Merge "Just use 'exception_to_unicode' to handle exception to string"
This commit is contained in:
commit
83384272f6
@ -26,6 +26,7 @@ import traceback
|
||||
import six
|
||||
|
||||
from oslo_utils._i18n import _LE
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import reflection
|
||||
from oslo_utils import timeutils
|
||||
|
||||
@ -205,26 +206,12 @@ def forever_retry_uncaught_exceptions(infunc):
|
||||
def inner_func(*args, **kwargs):
|
||||
last_exc_message = None
|
||||
same_failure_count = 0
|
||||
unknown_failure_count = 0
|
||||
watch = timeutils.StopWatch(duration=60)
|
||||
while True:
|
||||
try:
|
||||
return infunc(*args, **kwargs)
|
||||
except Exception as exc:
|
||||
try:
|
||||
this_exc_message = six.u(str(exc))
|
||||
except Exception:
|
||||
unknown_failure_count += 1
|
||||
try:
|
||||
logging.exception(
|
||||
_LE('Unexpected exception occurred %d'
|
||||
' time(s)... ') % unknown_failure_count)
|
||||
except Exception:
|
||||
# In case either serialization of the last exception
|
||||
# or logging failed, ignore the error
|
||||
pass
|
||||
else:
|
||||
unknown_failure_count = 0
|
||||
this_exc_message = encodeutils.exception_to_unicode(exc)
|
||||
if this_exc_message == last_exc_message:
|
||||
same_failure_count += 1
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user