From 107aa3b2ce43d3467cbeca600882da1c04f5850f Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Fri, 8 Sep 2023 12:16:38 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 563819222 --- google/colab/_serverextension/_resource_monitor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/google/colab/_serverextension/_resource_monitor.py b/google/colab/_serverextension/_resource_monitor.py index e4c8d9fd..dca9c073 100644 --- a/google/colab/_serverextension/_resource_monitor.py +++ b/google/colab/_serverextension/_resource_monitor.py @@ -128,8 +128,17 @@ def get_ram_usage(kernel_manager): # is better performed in the frontend presentation layer. 2) was only a # requirement for the split (KMC/K) container, a feature that was dropped # (cl/470476143). + def get_pid(kernel): + # TODO(b/264409633): Eliminate this function after migration to + # jupyter-client 7.x is complete. + try: + pid = kernel.provisioner.pid + except AttributeError: + pid = kernel.kernel.pid + return str(pid) + pids_to_kernel_ids = { - str(kernel_manager.get_kernel(kernel_id).kernel.pid): kernel_id + get_pid(kernel_manager.get_kernel(kernel_id)): kernel_id for kernel_id in kernel_manager.list_kernel_ids() }