Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions easypy/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand All @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions easypy/logging/_logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion easypy/threadtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down