From 2089f5e7e624f5c67725e9d1325edfcfd3e6d420 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 7 May 2024 17:01:04 -0400 Subject: [PATCH] Deal with normal generator from a plugin --- confluent_server/confluent/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 17fb8757..f41f580b 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -83,13 +83,15 @@ async def iterate_responses(responses): if inspect.isasyncgen(responses): async for rsp in responses: yield rsp - elif inspect.isgenerator(responses): + return + elif inspect.isgenerator(responses) or isinstance(responses, list) or isinstance(responses, tuple): for rsp in responses: yield rsp + return elif inspect.isawaitable(responses): responses = await responses - for rsp in responses: - yield rsp + for rsp in responses: + yield rsp def seek_element(currplace, currkey, depth): @@ -1307,7 +1309,7 @@ async def handle_path(path, operation, configmanager, inputdata=None, autostrip= return await handle_node_request(configmanager, inputdata, operation, pathcomponents, autostrip) elif pathcomponents[0] == 'discovery': - return disco.handle_api_request( + return await disco.handle_api_request( configmanager, inputdata, operation, pathcomponents) elif pathcomponents[0] == 'networking': return macmap.handle_api_request(