From 3d7c9b51a6a475a697fed862c35b6acefa046b59 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 5 Apr 2017 11:28:37 +0200 Subject: [PATCH] only consider stream outputs for data-rate limit --- notebook/notebookapp.py | 2 +- notebook/services/kernels/handlers.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index dac540550..af0cc9e58 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -997,7 +997,7 @@ class NotebookApp(JupyterApp): limited.""") iopub_data_rate_limit = Float(1000000, config=True, help="""(bytes/sec) - Maximum rate at which messages can be sent on iopub before they are + Maximum rate at which stream output can be sent on iopub before they are limited.""") rate_limit_window = Float(3, config=True, help="""(sec) Time window used to diff --git a/notebook/services/kernels/handlers.py b/notebook/services/kernels/handlers.py index 4b35f5a14..8ba8cd038 100644 --- a/notebook/services/kernels/handlers.py +++ b/notebook/services/kernels/handlers.py @@ -336,7 +336,10 @@ class ZMQChannelsHandler(AuthenticatedZMQStreamHandler): # Increment the bytes and message count self._iopub_window_msg_count += 1 - byte_count = sum([len(x) for x in msg_list]) + if msg_type == 'stream': + byte_count = sum([len(x) for x in msg_list]) + else: + byte_count = 0 self._iopub_window_byte_count += byte_count # Queue a removal of the byte and message count for a time in the @@ -357,7 +360,12 @@ class ZMQChannelsHandler(AuthenticatedZMQStreamHandler): The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable - `--NotebookApp.iopub_msg_rate_limit`.""")) + `--NotebookApp.iopub_msg_rate_limit`. + + Current values: + NotebookApp.iopub_msg_rate_limit={} (msgs/sec) + NotebookApp.rate_limit_window={} (secs) + """.format(self.iopub_msg_rate_limit, self.rate_limit_window))) else: # resume once we've got some headroom below the limit if self._iopub_msgs_exceeded and msg_rate < (0.8 * self.iopub_msg_rate_limit): @@ -374,7 +382,12 @@ class ZMQChannelsHandler(AuthenticatedZMQStreamHandler): The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable - `--NotebookApp.iopub_data_rate_limit`.""")) + `--NotebookApp.iopub_data_rate_limit`. + + Current values: + NotebookApp.iopub_data_rate_limit={} (bytes/sec) + NotebookApp.rate_limit_window={} (secs) + """.format(self.iopub_data_rate_limit, self.rate_limit_window))) else: # resume once we've got some headroom below the limit if self._iopub_data_exceeded and data_rate < (0.8 * self.iopub_data_rate_limit):