mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-30 19:36:24 +02:00
update method of terminate
This commit is contained in:
parent
4ef53a2eb3
commit
60fd49ea60
1 changed files with 17 additions and 2 deletions
|
|
@ -57,8 +57,23 @@ class ExecuteNbCode(Action):
|
|||
|
||||
async def terminate(self):
|
||||
"""kill NotebookClient"""
|
||||
if self.nb_client.km is not None:
|
||||
await self.nb_client._async_cleanup_kernel()
|
||||
if self.nb_client.km is not None and await self.nb_client.km.is_alive():
|
||||
await self.nb_client.km.shutdown_kernel(now=True)
|
||||
await self.nb_client.km.cleanup_resources()
|
||||
|
||||
# Stops all the running channels for this kernel
|
||||
# The stdin_channel is the channel for handling standard input to the kernel.
|
||||
if self.nb_client.kc.stdin_channel.is_alive():
|
||||
self.nb_client.kc.stdin_channel.stop()
|
||||
# The hb_channel is the channel for heartbeat communication between the kernel and client.
|
||||
if self.nb_client.kc.hb_channel.is_alive():
|
||||
self.nb_client.kc.hb_channel.stop()
|
||||
# The control_channel is the channel for controlling the kernel.
|
||||
if self.nb_client.kc.control_channel.is_alive():
|
||||
self.nb_client.kc.control_channel.stop()
|
||||
|
||||
self.nb_client.kc = None
|
||||
self.nb_client.km = None
|
||||
|
||||
async def reset(self):
|
||||
"""reset NotebookClient"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue