Skip to content

Commit

Permalink
Set parent context on instansiation
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Feb 10, 2016
1 parent e664e97 commit 9777c5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions synapse/util/logcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __nonzero__(self):
sentinel = Sentinel()

def __init__(self, name=None):
self.parent_context = None
self.parent_context = LoggingContext.current_context()
self.name = name
self.ru_stime = 0.
self.ru_utime = 0.
Expand Down Expand Up @@ -116,7 +116,12 @@ def set_current_context(cls, context):

def __enter__(self):
"""Enters this logging context into thread local storage"""
self.parent_context = self.set_current_context(self)
old_context = self.set_current_context(self)
if self.parent_context != old_context:
logger.warn(
"Expected parent context %r, found %r",
self.parent_context, old_context
)
self.alive = True
return self

Expand Down

0 comments on commit 9777c5f

Please sign in to comment.