From b63b17996005e5d1cd103cb30ac1d70e86b5896f Mon Sep 17 00:00:00 2001 From: Hans Kallekleiv <16436291+HansKallekleiv@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:48:58 +0200 Subject: [PATCH] make async --- backend/src/services/sumo_access/observation_access.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/services/sumo_access/observation_access.py b/backend/src/services/sumo_access/observation_access.py index 1a5f28586..428aed360 100644 --- a/backend/src/services/sumo_access/observation_access.py +++ b/backend/src/services/sumo_access/observation_access.py @@ -24,14 +24,14 @@ async def get_observations(self) -> Observations: name="observations", tagname="all", ) - if len(observations_collection) == 0: + if await observations_collection.length_async() == 0: return Observations() - if len(observations_collection) > 1: + if await observations_collection.length_async() > 1: raise ValueError(f"More than one observations dictionary found. {observations_collection.names}") - observations_handle: Dictionary = observations_collection[0] - observations_bytes = observations_handle.blob - observations_dict = json.loads(observations_bytes.decode()) + observations_handle: Dictionary = await observations_collection.getitem_async(0) + observations_byteio = await observations_handle.blob_async + observations_dict = json.loads(observations_byteio.getvalue().decode()) return Observations( summary=_create_summary_observations(observations_dict), rft=_create_rft_observations(observations_dict)