From 92129f1d47dd5daec15087337cf36ec52c5fe83c Mon Sep 17 00:00:00 2001 From: Alejo Sanchez Date: Tue, 13 Sep 2022 13:38:39 +0200 Subject: [PATCH] test.py: handle duplicate result from driver Sometimes the driver calls twice the callback on ready done future with a None result. Log it and avoid setting the local future twice. Signed-off-by: Alejo Sanchez --- test/topology/conftest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/topology/conftest.py b/test/topology/conftest.py index c28a675ba9..5f78a6483f 100644 --- a/test/topology/conftest.py +++ b/test/topology/conftest.py @@ -62,10 +62,16 @@ def _wrap_future(f: ResponseFuture) -> asyncio.Future: aio_future = loop.create_future() def on_result(result): - loop.call_soon_threadsafe(aio_future.set_result, result) + if not aio_future.done(): + loop.call_soon_threadsafe(aio_future.set_result, result) + else: + logger.debug("_wrap_future: on_result() on already done future: %s", result) def on_error(exception, *_): - loop.call_soon_threadsafe(aio_future.set_exception, exception) + if not aio_future.done(): + loop.call_soon_threadsafe(aio_future.set_exception, exception) + else: + logger.debug("_wrap_future: on_error() on already done future: %s"), result f.add_callback(on_result) f.add_errback(on_error)