Skip to content

Commit

Permalink
s/parent_context/previous_context/
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Feb 10, 2016
1 parent 9777c5f commit 00c9ad4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions synapse/util/logcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LoggingContext(object):
"""

__slots__ = [
"parent_context", "name", "usage_start", "usage_end", "main_thread",
"previous_context", "name", "usage_start", "usage_end", "main_thread",
"__dict__", "tag", "alive",
]

Expand Down Expand Up @@ -79,7 +79,7 @@ def __nonzero__(self):
sentinel = Sentinel()

def __init__(self, name=None):
self.parent_context = LoggingContext.current_context()
self.previous_context = LoggingContext.current_context()
self.name = name
self.ru_stime = 0.
self.ru_utime = 0.
Expand Down Expand Up @@ -117,10 +117,10 @@ def set_current_context(cls, context):
def __enter__(self):
"""Enters this logging context into thread local storage"""
old_context = self.set_current_context(self)
if self.parent_context != old_context:
if self.previous_context != old_context:
logger.warn(
"Expected parent context %r, found %r",
self.parent_context, old_context
"Expected previous context %r, found %r",
self.previous_context, old_context
)
self.alive = True
return self
Expand All @@ -131,7 +131,7 @@ def __exit__(self, type, value, traceback):
Returns:
None to avoid suppressing any exeptions that were thrown.
"""
current = self.set_current_context(self.parent_context)
current = self.set_current_context(self.previous_context)
if current is not self:
if current is self.sentinel:
logger.debug("Expected logging context %s has been lost", self)
Expand All @@ -141,11 +141,11 @@ def __exit__(self, type, value, traceback):
current,
self
)
self.parent_context = None
self.previous_context = None
self.alive = False

def copy_to(self, record):
"""Copy fields from this context and its parents to the record"""
"""Copy fields from this context to the record"""
for key, value in self.__dict__.items():
setattr(record, key, value)

Expand Down Expand Up @@ -226,7 +226,7 @@ def __enter__(self):
)

if self.current_context:
self.has_parent = self.current_context.parent_context is not None
self.has_parent = self.current_context.previous_context is not None
if not self.current_context.alive:
logger.debug(
"Entering dead context: %s",
Expand Down

0 comments on commit 00c9ad4

Please sign in to comment.