# Buggy code
def get_value(self, name):
    """Ask kernel for a value"""
    reason_big = _("The variable is too big to be retrieved")
    reason_not_picklable = _("The variable is not picklable")
    reason_dead = _("The kernel is dead")
    reason_other = _("An error occured, see the console.")
    msg = _(
        "%s.<br><br>"
        "Note: Please don't report this problem on Github, "
        "there's nothing to do about it."
    )
    try:
        return self.call_kernel(
            interrupt=True,
            blocking=True,
            display_error=True,
            timeout=CALL_KERNEL_TIMEOUT,
        ).get_value(name)
    except TimeoutError:
        raise ValueError(msg % reason_big)
    except (PicklingError, UnpicklingError):
        raise ValueError(msg % reason_not_picklable)
    except RuntimeError:
        raise ValueError(msg % reason_dead)
    except KeyError:
        raise
    except Exception:
        raise ValueError(msg % reason_other)


# Traceback (TimeoutError)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
handler(msg)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 172, in _handle_execute_reply
self.refresh_namespacebrowser()
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 63, in refresh_namespacebrowser
callback=self.set_namespace_view
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.
Traceback (most recent call last):
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
handler(msg)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 172, in _handle_execute_reply
self.refresh_namespacebrowser()
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py", line 63, in refresh_namespacebrowser
callback=self.set_namespace_view
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.
Traceback (most recent call last):
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 554, in set_current_client_working_directory
shellwidget.set_cwd(directory)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/shell.py", line 178, in set_cwd
self.call_kernel(interrupt=True).set_cwd(dirname)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder_kernels/comms/commbase.py", line 538, in __call__
call_dict, call_data, self._comm_id)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 130, in _get_call_return_value
with self.comm_channel_manager(comm_id, queue_message=not interrupt):
File "/home/nerohmot/my-envs/s4/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 87, in comm_channel_manager
timeout)
File "/home/nerohmot/my-envs/s4/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/comms/kernelcomm.py", line 168, in _wait
raise TimeoutError(timeout_msg)
TimeoutError: Timeout while waiting for comm port.

# Fixed code
def get_value(self, name):
    """Ask kernel for a value"""
    reason_big = _("The variable is too big to be retrieved")
    reason_not_picklable = _("The variable is not picklable")
    reason_dead = _("The kernel is dead")
    reason_other = _("An error occured, see the console.")
    reason_comm = _("The comm channel is not working.")
    msg = _(
        "%s.<br><br>"
        "Note: Please don't report this problem on Github, "
        "there's nothing to do about it."
    )
    try:
        return self.call_kernel(
            blocking=True, display_error=True, timeout=CALL_KERNEL_TIMEOUT
        ).get_value(name)
    except TimeoutError:
        raise ValueError(msg % reason_big)
    except (PicklingError, UnpicklingError):
        raise ValueError(msg % reason_not_picklable)
    except RuntimeError:
        raise ValueError(msg % reason_dead)
    except KeyError:
        raise
    except CommError:
        raise ValueError(msg % reason_comm)
    except Exception:
        raise ValueError(msg % reason_other)