def send_execute_reply(self, stream, ident, parent, metadata, reply_content):

            # This function is mostly copy-pasted from the last part of
            # ipykernel's execute_reply method.
            # It is extracted to allow overriding in subclasses.
            # Splash kernel overrides it for async replies: instead
            # of returning result immediately it only calls the original
            # implementation when async reply is received.

            content = parent[u'content']
            stop_on_error = content.get('stop_on_error', True)
            silent = content[u'silent']

            # ============ BEGIN COPY-PASTE ============

            # Flush output before sending the reply.
            sys.stdout.flush()
            sys.stderr.flush()
            # FIXME: on rare occasions, the flush doesn't seem to make it to the
            # clients... This seems to mitigate the problem, but we definitely need
            # to better understand what's going on.
            if self._execute_sleep:
                time.sleep(self._execute_sleep)

            # Send the reply
            reply_content = json_clean(reply_content)
            metadata = self.finish_metadata(parent, metadata, reply_content)

            reply_msg = self.session.send(stream, u'execute_reply',
                                          reply_content, parent, metadata=metadata,
                                          ident=ident)
            self.log.debug("%s", reply_msg)

            if not silent and reply_msg['content']['status'] == u'error' and stop_on_error:
                self._abort_queues()

            # ============== END COPY-PASTE ==============

            # fix idle signal handling for async replies
            self._publish_idle()
            if hasattr(stream, 'flush'):
                stream.flush()
Send a reply to execute_request
dataset/ETHPy150Open scrapinghub/splash/splash/kernel/kernelbase.py/Kernel.send_execute_reply