diff --git a/easypy/caching.py b/easypy/caching.py index f29bbca..7463820 100644 --- a/easypy/caching.py +++ b/easypy/caching.py @@ -181,6 +181,10 @@ class _CachedException(tuple): pass +def _default_key_func(*args, **kwargs): + return _make_key(args, kwargs, False) + + class _TimeCache(DecoratingDescriptor): def __init__(self, func, **kwargs): @@ -196,8 +200,7 @@ def __init__(self, func, **kwargs): key_func = kwargs['key_func'] if not key_func: - def key_func(*args, **kwargs): - return _make_key(args, kwargs, False) + key_func = _default_key_func self._key_func = key_func self.NOT_FOUND = object() @@ -210,7 +213,11 @@ def key_func(*args, **kwargs): def make_key(self, args, kwargs): bound = self.sig.bind(*args, **kwargs) _apply_defaults(bound) - return kwargs_resilient(self._key_func)(**bound.arguments) + + if self._key_func is _default_key_func: + return self._key_func(**bound.arguments) + else: + return kwargs_resilient(self._key_func)(**bound.arguments) def key_func(self, func): """ diff --git a/easypy/logging/_logbook.py b/easypy/logging/_logbook.py index 2eabd02..0657db2 100644 --- a/easypy/logging/_logbook.py +++ b/easypy/logging/_logbook.py @@ -227,10 +227,10 @@ def process(self, record): if extra is not None: decoration = extra.pop('decoration', decoration) - contexts = THREAD_LOGGING_CONTEXT.context extra = THREAD_LOGGING_CONTEXT.flatten() - extra['context'] = "[%s]" % ";".join(contexts) if contexts else "" + contexts = extra['context'] record.extra.update(extra) + record.extra['context'] = "[%s]" % ";".join(contexts) if contexts else "" indentation = record.extra['indentation'] indents = chain(repeat(G.graphics.INDENT_SEGMENT, indentation), repeat(decoration, 1)) diff --git a/easypy/threadtree.py b/easypy/threadtree.py index 7e84eaa..446e31a 100644 --- a/easypy/threadtree.py +++ b/easypy/threadtree.py @@ -487,7 +487,7 @@ def _get_context_data(self, thread_uuid=None, combined=False): parent_uuid = get_parent_uuid(thread_uuid) if parent_uuid: parent_ctx = self._get_context_data(parent_uuid, combined=True) - ctx = deepcopy(parent_ctx) + ctx + ctx = parent_ctx + ctx return ctx def get(self, k, default=None):