From eb487d23a0362d4957fe4bb19b4cd578f221640c Mon Sep 17 00:00:00 2001 From: Abel Legese <73869888+Abellegese@users.noreply.github.com> Date: Thu, 24 Oct 2024 21:59:19 +0300 Subject: [PATCH] Fixing PR/Build Error: Adding event loop on async execution --- ersilia/serve/standard_api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ersilia/serve/standard_api.py b/ersilia/serve/standard_api.py index ed50b09e0..77b4d976e 100644 --- a/ersilia/serve/standard_api.py +++ b/ersilia/serve/standard_api.py @@ -278,8 +278,12 @@ def serialize_to_json(self, input_data): h = next(reader) if len(h) == 1: self.logger.debug("One column found in input") - loop = asyncio.get_event_loop() - return loop.run_until_complete(self.async_serialize_to_json_one_columns(input_data)) + try: + loop = asyncio.get_running_loop() + return loop.run_until_complete(self.async_serialize_to_json_one_columns(input_data)) + except RuntimeError: # If there's no running loop, Start a new one + loop = asyncio.get_event_loop() + return loop.run_until_complete(self.async_serialize_to_json_one_columns(input_data)) elif len(h) == 2: self.logger.debug("Two columns found in input") return self.serialize_to_json_two_columns(input_data=input_data)