From b141cf0deee4f2b43faffc115e2240ffe5c07002 Mon Sep 17 00:00:00 2001 From: John Andersen Date: Fri, 7 Jun 2019 14:28:26 -0700 Subject: [PATCH] util: asynchelper: aenter_stack bind lambdas Signed-off-by: John Andersen --- CHANGELOG.md | 1 + dffml/util/asynchelper.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c10bd1b2f8..5c35820923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - skel modules have `long_description_content_type` set to "text/markdown" - Base Orchestrator `__aenter__` and `__aexit__` methods were moved to the Memory Orchestrator because they are specific to that config. +- Async helper `aenter_stack` uses `inspect.isfunction` so it will bind lambdas ## [0.2.0] - 2019-05-23 ### Added diff --git a/dffml/util/asynchelper.py b/dffml/util/asynchelper.py index 89848f09e0..52a03c0c6a 100644 --- a/dffml/util/asynchelper.py +++ b/dffml/util/asynchelper.py @@ -127,8 +127,7 @@ async def aenter_stack( if context_managers is not None: for key, ctxmanager in context_managers.items(): if call: - # Bind if not bound - if hasattr(ctxmanager, "__self__"): + if inspect.isfunction(ctxmanager): ctxmanager = ctxmanager.__get__(obj, obj.__class__) setattr( obj, key, await stack.enter_async_context(ctxmanager())