emacs-jupyter/jupyter-channel-ioloop.el

208 lines
8 KiB
EmacsLisp
Raw Permalink Normal View History

Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;;; jupyter-channel-ioloop.el --- Abstract class to communicate with a jupyter-channel in a subprocess -*- lexical-binding: t -*-
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
2020-04-07 15:13:51 -05:00
;; Copyright (C) 2019-2020 Nathaniel Nicandro
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
;; Author: Nathaniel Nicandro <nathanielnicandro@gmail.com>
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;; Created: 27 Jun 2019
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
2019-05-31 09:44:39 -05:00
;; published by the Free Software Foundation; either version 3, or (at
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;; Define a `jupyter-ioloop' that can be sent events to start, stop, or send a
2020-03-11 20:50:52 +09:00
;; message on a set of `jupyter-channel' objects. For example to start a
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;; `jupyter-channel' in the subprocess environment you would do something like
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
;;
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;; (jupyter-send ioloop 'start-channel TYPE ENDPOINT)
;;
;; where TYPE and ENDPOINT have the same meaning as in `jupyter-channel'.
;;
;; Note by default, no channels are available in the subprocess environment.
;; You initialize channels by setting the `jupyter-channel-ioloop-channels'
;; variable in the subprocess environment, e.g. using
;; `jupyter-ioloop-add-setup', before starting the `jupyter-ioloop'.
;;
;; When you call `jupyter-ioloop-start' a `jupyter-session' object needs to
;; passed as the second argument with whatever object you would like to receive
2020-03-11 20:50:52 +09:00
;; events as the third. The `jupyter-session-id' will be used as the value of
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;; the :identity key in the call to `jupyter-start-channel' when starting a
;; channel.
;;
;; Each event sent to the subprocess will send back a corresponding
;; confirmation event, the three events that can be sent and their
;; corresponding confirmation events are:
;;
;; (start-channel TYPE ENDPOINT) -> (start-channel TYPE)
;; (stop-channel TYPE) -> (stop-channel TYPE)
;; (send TYPE MSG-TYPE MSG MSG-ID) -> (sent MSG-ID)
;;
;; For the send event, the MSG-TYPE, MSG, and MSG-ID have the same meaning as
;; the TYPE, MSG, and MSG-ID arguments of the `jupyter-send' method of a
;; `jupyter-channel'.
;;
;; Ex.
;;
;; (let ((ioloop (jupyter-channel-ioloop))
;; (session (jupyter-session :id ...)))
;; (jupyter-start-ioloop ioloop session ...)
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
;; ...
;; (jupyter-send ioloop 'start-channel ...)
;; ...)
;;; Code:
(require 'jupyter-ioloop)
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(defvar jupyter-channel-ioloop-session nil
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
"The `jupyter-session' used when initializing Jupyter channels.")
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(defvar jupyter-channel-ioloop-channels nil
"A list of synchronous channels in an ioloop controlling Jupyter channels.")
2018-11-13 17:56:16 -06:00
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(jupyter-ioloop-add-arg-type jupyter-channel
(lambda (arg)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
`(or (object-assoc ,arg :type jupyter-channel-ioloop-channels)
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(error "Channel not alive (%s)" ,arg))))
2018-11-13 17:56:16 -06:00
(defclass jupyter-channel-ioloop (jupyter-ioloop)
()
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
:abstract t)
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(cl-defmethod initialize-instance ((ioloop jupyter-channel-ioloop) &optional _slots)
(cl-call-next-method)
(jupyter-ioloop-add-setup ioloop
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(require 'jupyter-channel-ioloop))
(jupyter-channel-ioloop-add-start-channel-event ioloop)
(jupyter-channel-ioloop-add-stop-channel-event ioloop)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(jupyter-channel-ioloop-add-send-event ioloop)
(jupyter-ioloop-add-teardown ioloop
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(mapc #'jupyter-stop-channel jupyter-channel-ioloop-channels)))
2018-11-13 17:56:16 -06:00
(defun jupyter-channel-ioloop--set-session (ioloop session)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
"In the IOLOOP, set SESSION as the `jupyter-channel-ioloop-session'.
Add a form to IOLOOP's setup that sets the variable
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
`jupyter-channel-ioloop-session' to a `jupyter-session' based on
2020-03-11 20:50:52 +09:00
SESSION's id and key. Remove any top level form in the setup that
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
sets `jupyter-channel-ioloop-session' via `setq' before doing so."
(cl-callf (lambda (setup)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(cons `(setq jupyter-channel-ioloop-session
(jupyter-session
:id ,(jupyter-session-id session)
:key ,(jupyter-session-key session)))
(cl-remove-if
(lambda (f) (and (eq (car f) 'setq)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(eq (cadr f) 'jupyter-channel-ioloop-session)))
setup)))
(oref ioloop setup)))
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(cl-defmethod jupyter-ioloop-start ((ioloop jupyter-channel-ioloop)
(session jupyter-session)
obj &key buffer)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
"Start IOLOOP, using SESSION to set the `jupyter-channel-ioloop-session'.
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
Add setup forms to IOLOOP that will initialize the
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
`jupyter-channel-ioloop-session' variable to a `jupyter-session'
2020-03-11 20:50:52 +09:00
based on SESSION's id and key. Also add
`jupyter-ioloop-recv-messages' to `jupyter-ioloop-post-hook'. In
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
addition add the events send, start-channel, and stop-channel
2020-03-11 20:50:52 +09:00
that the parent Emacs process can send to the IOLOOP. See
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
`jupyter-channel-ioloop-add-send-event',
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
`jupyter-channel-ioloop-add-start-channel-event', and
`jupyter-ioloop-add-stop-channel-event'.
2020-03-11 20:50:52 +09:00
After doing the above initialization, start the IOLOOP. OBJ and
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
BUFFER have the same meaning as in the method definition for
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
`jupyter-ioloop'."
(jupyter-channel-ioloop--set-session ioloop session)
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(cl-call-next-method ioloop obj :buffer buffer))
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
;;; Channel events
2018-11-13 17:56:16 -06:00
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(defun jupyter-channel-ioloop-add-start-channel-event (ioloop)
"Add a start-channel event handler to IOLOOP.
The event fires when the IOLOOP receives a list with the form
(start-channel CHANNEL-TYPE ENDPOINT)
and shall stop any existing channel with CHANNEL-TYPE and start a
2020-03-11 20:50:52 +09:00
new channel with CHANNEL-TYPE connected to ENDPOINT. The
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
underlying socket IDENTITY is derived from
2020-03-11 20:50:52 +09:00
`jupyter-channel-ioloop-session' in the IOLOOP environment. The
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
channel will be added to the variable
`jupyter-channel-ioloop-channels' in the IOLOOP environment.
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
Note, before sending this event to IOLOOP, the corresponding
channel needs to be available in the
2020-03-11 20:50:52 +09:00
`jupyer-channel-ioloop-channels' variable. You can initialize
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
this variable in the setup form of IOLOOP.
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
A list with the form
(start-channel CHANNEL-TYPE)
is returned to the parent process."
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(jupyter-ioloop-add-event
ioloop start-channel ((channel jupyter-channel) endpoint)
;; Stop the channel if it is already alive
(when (jupyter-channel-alive-p channel)
(jupyter-stop-channel channel))
;; Start the channel
(oset channel endpoint endpoint)
(let ((identity (jupyter-session-id jupyter-channel-ioloop-session)))
(jupyter-start-channel channel :identity identity))
(list 'start-channel (oref channel type))))
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(defun jupyter-channel-ioloop-add-stop-channel-event (ioloop)
"Add a stop-channel event handler to IOLOOP.
The event fires when the IOLOOP receives a list with the form
(stop-channel CHANNEL-TYPE)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
If a channel with CHANNEL-TYPE exists and is alive, it is stopped.
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
A list with the form
(stop-channel CHANNEL-TYPE)
is returned to the parent process."
(jupyter-ioloop-add-event ioloop stop-channel (type)
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
(let ((channel (object-assoc type :type jupyter-channel-ioloop-channels)))
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(when (and channel (jupyter-channel-alive-p channel))
(jupyter-stop-channel channel))
(list 'stop-channel type))))
(defun jupyter-channel-ioloop-add-send-event (ioloop)
"Add a send event handler to IOLOOP.
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
The event fires when the IOLOOP receives a list of the form
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(send CHANNEL-TYPE MSG-TYPE MSG MSG-ID)
and calls (jupyter-send CHANNEL MSG-TYPE MSG MSG-ID) using the
channel corresponding to CHANNEL-TYPE in the IOLOOP environment.
Make `jupyter-channel-ioloop` independent of `zmq` This change localizes all `zmq` related functionality to `jupyter-ioloop` and `jupyter-zmq-*` files. * jupyter-channel-ioloop-comm.el: Add better commentary. (jupyter-base): Require. (jupyter-channel-ioloop-comm): Add `ioloop-class` slot (initialize-instance [jupyter-channel-ioloop-comm]): Use it. * jupyter-channel-ioloop.el (jupyter-base, jupyter-zmq-channel): Un-require. (jupyter-ioloop-session, jupyter-ioloop-channels): Rename to `jupyter-channel-ioloop-session` `jupyter-channel-ioloop-channels` and update all callers. (jupyter-channel-ioloop): Make into an abstract class. (initialize-instance [jupyter-channel-ioloop]): Re-add `jupyter-channel-ioloop-add-send-event`. Don't add to `jupyter-ioloop-post-hook`. (jupyter-channel-ioloop-recv-messages): Remove. (jupyter-channel-ioloop--set-session, jupyter-ioloop-start) (jupyter-channel-ioloop-add-send-event): Doc changes. (jupyter-channel-ioloop-add-start-channel-event) (jupyter-channel-ioloop-add-stop-channel-event): Don't add/remove from the `jupyter-ioloop-poller`. Now expected to be handled in the `jupyter-channel` subclass. Update documentation. In addition, for the start-channel event, do not attempt to add a channel if one doesn't already exist. * jupyter-ioloop.el (jupyter-ioloop-add-teardown): Remove mention of `jupyter-channel-ioloop` behavior. (jupyter-ioloop-add-arg-type): Update example variable. (jupyter-ioloop-environment-p): New function. * jupyter-kernel-manager.el (jupyter-channel): Require. (jupyter-make-client): Require and use `jupyter-zmq-channel-ioloop`. (jupyter-start-channels): Use `make-instance`. (jupyter-interrupt-kernel): Remove `condition-case`. Not needed since preventing socket blocking is now handled by `jupyter-recv`. * jupyter-repl.el (jupyter-connect-repl): Require and use `jupyter-zmq-channel-ioloop`. * jupyter-zmq-channel-ioloop.el: New file. * jupyter-zmq-channel.el (jupyter-ioloop-poller-remove) (jupyter-ioloop-poller-add): New declares. (jupyter-start-channel): Add to `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-stop-channel): Only disconnect the socket from its endpoint instead of closing it, leave that up to garbage collection. Remove from `jupyter-ioloop-poller` when in `jupyter-ioloop-environment-p`. (jupyter-recv): Handle non-blocking. * test/jupyter-test.el (jupyter-zmq-channel): Use non-blocking `zmq-send` since socket is no longer closed when calling `jupyter-stop-channel`. (jupyter-ioloop-test-eval-ioloop): Rename to `jupyter-test-ioloop-eval-event`, update all callers, and move to `test/test-helper.el`. (jupyter-channel-ioloop-send-event, jupyter-channel-ioloop-stop-channel-event) (jupyter-channel-ioloop-start-channel-event): Fix tests for variable name changes. Use `jupyter-test-channel-ioloop`. Update `jupyter-ioloop-poller`, addition/removal from poller is now done in the `jupyter-channel` subclass by checking `jupyter-ioloop-environment-p`. * test/test-helper.el (jupyter-zmq-channel-ioloop): Require. (initialize-instance [jupyter-echo-client]): Use it. (jupyter-test-channel-ioloop): New macro. (jupyter-test-ioloop-eval-event): New function.
2019-06-28 20:44:13 -05:00
A list of the form
Add `jupyter-channel-ioloop` This commit extracts out the IOLoop functions which are used to define an IOLoop that send and receive messages on Jupyter channels into is own object. * jupyter-channel-ioloop.el: New file. (jupyter-channel-ioloop): A sub-type of `jupyter-ioloop` that sets up an IOLoop to send/receive messages on Jupyter channels. (jupyter-ioloop-channels): (jupyter-ioloop-session): New variables used in `jupyter-channel-ioloop` events. (jupyter-ioloop-add-arg-type jupyter-channel): Moved from `jupyter-client.el`. (jupyter-channel-ioloop-add-session): New function. (jupyter-ioloop-start): Setup ioloop to communicate with Jupyter channels. (jupyter-channel-ioloop-recv-messages): (jupyter-channel-ioloop-add-start-channel-event): (jupyter-channel-ioloop-add-stop-channel-event): (jupyter-channel-ioloop-add-send-event): Moved from `jupyter-client.el`, replaced jupyter-ioloop prefix with jupyter-channel-ioloop. * jupyter-client.el: Require `jupyter-channel-ioloop` instead of `jupyter-ioloop`. (jupyter-kernel-client): Change type of `ioloop` to `jupyter-channel-ioloop`. (jupyter-client--ioloop-setup-form): Remove. (jupyter-ioloop-add-arg-type jupyter-channel): Move to `jupyter-channel-ioloop.el`. (jupyter-ioloop-add-start-channel-event): (jupyter-ioloop-add-stop-channel-event): (jupyter-ioloop-add-send-event): Move to `jupyter-channel-ioloop.el`, replace jupyter-ioloop prefix with jupyter-channel-ioloop. (jupyter-ioloop-start): Remove. (jupyter-start-channels): Ensure `jupyter-ioloop-start` method of `jupyter-channel-ioloop` is called. Set ioloop process buffer to `-buffer` slot of client. * jupyter-ioloop.el (jupyter-ioloop-start): Remove :before method.
2018-11-08 11:11:10 -06:00
(sent CHANNEL-TYPE MSG-ID)
is returned to the parent process."
(jupyter-ioloop-add-event
ioloop send ((channel jupyter-channel) msg-type msg msg-id)
(list 'sent (oref channel type)
(jupyter-send channel msg-type msg msg-id))))
(provide 'jupyter-channel-ioloop)
;;; jupyter-channel-ioloop.el ends here