From 623b2b34c70679ae70f22cb28474fe6c62046ce9 Mon Sep 17 00:00:00 2001 From: fecet Date: Wed, 21 Jun 2023 14:54:45 +0800 Subject: [PATCH] check env in kwargs --- jupyter_client/provisioning/local_provisioner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jupyter_client/provisioning/local_provisioner.py b/jupyter_client/provisioning/local_provisioner.py index 8abc1b84..be79eedf 100644 --- a/jupyter_client/provisioning/local_provisioner.py +++ b/jupyter_client/provisioning/local_provisioner.py @@ -186,8 +186,11 @@ async def pre_launch(self, **kwargs: Any) -> Dict[str, Any]: km.hb_port = lpc.find_available_port(km.ip) km.control_port = lpc.find_available_port(km.ip) self.ports_cached = True - - km.write_connection_file(jupyter_session=kwargs['env'].get("JPY_SESSION_NAME", "")) + if 'env' in kwargs: + jupyter_session = kwargs['env'].get("JPY_SESSION_NAME", "") + km.write_connection_file(jupyter_session=jupyter_session) + else: + km.write_connection_file() self.connection_info = km.get_connection_info() kernel_cmd = km.format_kernel_cmd(