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 <alejo.sanchez@scylladb.com>
This commit is contained in:
Alejo Sanchez
2022-09-13 13:38:39 +02:00
parent 2da7304696
commit 92129f1d47

View File

@@ -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)