Merge "Log an error on an uncaught exception in a thread"
This commit is contained in:
commit
1c4fdf564e
@ -120,9 +120,20 @@ class ThreadGroupManager(object):
|
|||||||
"""Run the given method in a sub-thread."""
|
"""Run the given method in a sub-thread."""
|
||||||
if stack_id not in self.groups:
|
if stack_id not in self.groups:
|
||||||
self.groups[stack_id] = threadgroup.ThreadGroup()
|
self.groups[stack_id] = threadgroup.ThreadGroup()
|
||||||
return self.groups[stack_id].add_thread(self._start_with_trace,
|
|
||||||
self._serialize_profile_info(),
|
def log_exceptions(gt):
|
||||||
func, *args, **kwargs)
|
try:
|
||||||
|
gt.wait()
|
||||||
|
except Exception:
|
||||||
|
LOG.exception(_LE('Unhandled error in asynchronous task'))
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
th = self.groups[stack_id].add_thread(self._start_with_trace,
|
||||||
|
self._serialize_profile_info(),
|
||||||
|
func, *args, **kwargs)
|
||||||
|
th.link(log_exceptions)
|
||||||
|
return th
|
||||||
|
|
||||||
def start_with_lock(self, cnxt, stack, engine_id, func, *args, **kwargs):
|
def start_with_lock(self, cnxt, stack, engine_id, func, *args, **kwargs):
|
||||||
"""Run the method in sub-thread if acquire a stack lock is successful.
|
"""Run the method in sub-thread if acquire a stack lock is successful.
|
||||||
|
Loading…
Reference in New Issue
Block a user