Store and log correct exception info
Since OVSDB commands execute in a different thread, the exceptions that are passed to the original thread do not contain traceback info from the exception. This patch stores the text from the exception as it is caught so that the calling thread can log it. Change-Id: If462c3d5dc104b349218dc910aa281220a5af528
This commit is contained in:
parent
c4729e8805
commit
2756d9efe0
|
@ -64,8 +64,11 @@ class Transaction(api.Transaction):
|
|||
def commit(self):
|
||||
ovsdb_connection.queue_txn(self)
|
||||
result = self.results.get()
|
||||
if isinstance(result, Exception) and self.check_error:
|
||||
raise result
|
||||
if self.check_error:
|
||||
if isinstance(result, idlutils.ExceptionResult):
|
||||
if self.log_errors:
|
||||
LOG.error(result.tb)
|
||||
raise result.ex
|
||||
return result
|
||||
|
||||
def do_commit(self):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import os
|
||||
import Queue
|
||||
import threading
|
||||
import traceback
|
||||
|
||||
from ovs.db import idl
|
||||
from ovs import poller
|
||||
|
@ -80,7 +81,9 @@ class Connection(object):
|
|||
try:
|
||||
txn.results.put(txn.do_commit())
|
||||
except Exception as ex:
|
||||
txn.results.put(ex)
|
||||
er = idlutils.ExceptionResult(ex=ex,
|
||||
tb=traceback.format_exc())
|
||||
txn.results.put(er)
|
||||
self.txns.task_done()
|
||||
|
||||
def queue_txn(self, txn):
|
||||
|
|
|
@ -21,6 +21,12 @@ from ovs import poller
|
|||
from ovs import stream
|
||||
|
||||
|
||||
class ExceptionResult(object):
|
||||
def __init__(self, ex, tb):
|
||||
self.ex = ex
|
||||
self.tb = tb
|
||||
|
||||
|
||||
def get_schema_helper(connection):
|
||||
err, strm = stream.Stream.open_block(
|
||||
stream.Stream.open(connection))
|
||||
|
|
Loading…
Reference in New Issue