Skip to content

Commit

Permalink
Fixing PR/Build Error: Adding event loop on async execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Abellegese authored Oct 24, 2024
1 parent 7080f49 commit eb487d2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ersilia/serve/standard_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb487d2

Please sign in to comment.