In jupyter server, last_activity is patched into ptywclients in handler
class TermSocket(WebSocketMixin, JupyterHandler, terminado.TermSocket):
...
def _update_activity(self):
self.application.settings["terminal_last_activity"] = utcnow()
# terminal may not be around on deletion/cull
if self.term_name in self.terminal_manager.terminals:
self.terminal_manager.terminals[self.term_name].last_activity = utcnow()
If we close the browser or refresh it, these is no socket to update last_activity
Also if we execute some time consuming terminal(like below), last_activity will not be updated
$python
Python 3.8.12 (default, Dec 21 2021, 07:30:29)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> while True:
... time.sleep(1)
... print(1)
...
So this PR introduces pre_pty_read_hook, which allows the jupyter server's TerminalManager to update the pty when it is reading
in jupyter server (I will create a pr in jupyter server as well)
class TerminalManager(LoggingConfigurable, terminado.NamedTermManager):
def pre_pty_read_hook(self, ptywclients):
ptywclients.last_activity = utcnow()
In jupyter server,
last_activity
is patched into ptywclients in handlerIf we close the browser or refresh it, these is no socket to update
last_activity
Also if we execute some time consuming terminal(like below),
last_activity
will not be updatedSo this PR introduces
pre_pty_read_hook
, which allows the jupyter server's TerminalManager to update the pty when it is readingin jupyter server (I will create a pr in jupyter server as well)