process: Fix wrong use of log.ctx(self)

That's not needed and will produce some parent loop detection in
log.find_on_stack() if logging is called under that stack frame.

Change-Id: I4ab7e8977fa9bad5c8956b7c1df1513b27bb5aa2
This commit is contained in:
Pau Espin 2020-06-04 16:11:37 +02:00
parent eb7ced1367
commit 19fe3a1caf
2 changed files with 6 additions and 3 deletions

View File

@ -318,8 +318,12 @@ def ctx_obj(origin_or_str):
f = sys._getframe(2)
if origin_or_str is None:
f.f_locals.pop(LOG_CTX_VAR, None)
else:
f.f_locals[LOG_CTX_VAR] = origin_or_str
return
if isinstance(origin_or_str, Origin) and origin_or_str is f.f_locals.get('self'):
# Avoid adding log ctx in stack frame where Origin it is already "self",
# it is not needed and will make find_on_stack() to malfunction
raise Error('Don\'t use log.ctx(self), it\'s not needed!')
f.f_locals[LOG_CTX_VAR] = origin_or_str
class OriginLoopError(Error):
pass

View File

@ -196,7 +196,6 @@ class Process(log.Origin):
self.terminate()
raise e
if raise_nonsuccess and self.result != 0:
log.ctx(self)
raise log.Error('Exited in error %d' % self.result)
return self.result