We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e3b63d commit 0c32ef1Copy full SHA for 0c32ef1
llmstack/play/utils.py
@@ -75,7 +75,7 @@ def extract_variables(expression):
75
return variables
76
77
78
-def run_coro_in_new_loop(coro):
+def run_coro_in_new_loop(coro, name=None):
79
def start_loop(loop):
80
asyncio.set_event_loop(loop)
81
loop.run_forever()
@@ -86,8 +86,12 @@ def _done_callback(future):
86
except CancelledError:
87
logger.info("Task cancelled")
88
except Exception as e:
89
- logger.exception(f"Task failed with error: {e}")
+ logger.error(f"Task in loop {name} failed with error: {e}")
90
finally:
91
+ # Find and cancel all pending tasks before stopping the loop
92
+ for task in asyncio.all_tasks(loop):
93
+ task.cancel()
94
+
95
loop.stop()
96
97
loop = asyncio.new_event_loop()
0 commit comments