mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user