Commit graph

12 commits

Author SHA1 Message Date
Nathaniel Nicandro
1fa6ed4e5f Remove the jupyter-ioloop-handler method
Replace it with a handler function passed to `jupyter-ioloop-start`.

* jupyter-ioloop-comm.el: Do it.

* jupyter-channel-ioloop-comm.el: Do it.

* jupyter-channel-ioloop-comm.el: Do it.

* jupyter-ioloop.el: Do it. Update comments and doc.
(jupyter-ioloop--delete-process): Remove. It was used to perform
cleanup when the object used for dispatching to a handler method was
garbage collected. Since we no longer rely on having an object for
dispatching, preferring just a function to call, its not needed.

(jupyter-ioloop--make-filter): Fall back to calling handler function
instead of `jupyter-ioloop-handler`. Only handle ioloop start/stop
events internally. This means we can remove the check for those in
`jupyter-ioloop-comm`.

* test/jupyter-test.el: Update tests to take into account above
  changes.
2021-04-22 09:51:36 -05:00
Nathaniel Nicandro
786f61fb99 Remove jupyter-session based jupyter-ioloop-start implementation
This in preparation for removing the `jupyter-ioloop-handler` method
altogether.

* jupyter-ioloop-comm.el
(jupyter-channel-ioloop--set-session): Promote to public function.
(jupyter-ioloop-start): Remove `jupyter-session` based
implementation. Preferring sub-classes to call
`jupyter-channel-ioloop-set-session`.

* jupyter-channel-ioloop-comm.el
(jupyter-comm-initialize): Use the newly public function.
2021-04-22 09:51:36 -05:00
Nathaniel Nicandro
71789f7cfd Remove more jupyter-channels-running-p implementations
The implementations are really aliases of `jupyter-comm-alive-p` so
keep that one instead.  The `jupyter-channels-running-p` method is a
remnant of an older design, still used by `jupyter-kernel-client'
though.

* jupyter-channel-ioloop-comm.el: Do it.

* jupyter-server.el: Do it.
2020-04-14 17:05:28 -05:00
Nathaniel Nicandro
403c70c83c Bump version 2020-04-07 15:13:51 -05:00
Nathaniel Nicandro
1c45c3226b Mass rename of jupyter-comm-layer related functions
The following changes are made:

    `jupyter-initialize-connection` -> `jupyter-comm-initialize`
    `jupyter-connect-client` -> `jupyter-comm-add-handler`
    `jupyter-disconnect-client` -> `jupyter-comm-remove-handler`
    `jupyter-comm-client-loop` -> `jupyter-comm-handler-loop`

* README.org: Do it.

* jupyter-channel-ioloop-comm: Do it.

* jupyter-client.el: Do it.

* jupyter-comm-layer.el: Do it.
(jupyter-comm-layer): Rename `clients` slot to `handlers`. Update all uses.

* jupyter-kernel-process-manager.el: Do it.

* jupyter-repl.el: Do it.

* jupyter-server.el: Do it.

* jupyter-zmq-channel-comm.el: Do it.

* test/jupyter-server-test.el: Do it.

* test/jupyter-test.el: Do it.
2020-03-29 03:08:53 -05:00
conao3
fb8c2c75fd two spaces after a period 2020-03-12 18:20:15 -05:00
conao3
1546a72f57 clean header 2020-03-10 23:39:35 -05:00
Nathaniel Nicandro
dcf80d51db Remove jupyter-comm--channel
Since we are using keyword to represent channels on the client level, use a
plist of channels on the comm layer level instead of channel slots. This allows
us to remove `jupyter-comm-channel` and simplify the relevant code somewhat.
2019-09-17 11:42:21 -05:00
Nathaniel Nicandro
6650dd3588 Bump version 2019-07-24 16:03:22 -05:00
Nathaniel Nicandro
bf5589e428 Avoid use of jupyter-ioloop-wait-until
* jupyter-channel-ioloop-comm.el (jupyter-stop-channel)
(jupyter-start-channel): Do it.

See https://github.com/dzop/emacs-jupyter/issues/148#issuecomment-511219046

In reality `jupyter-ioloop-wait-until` should be fixed to handle the case of
multiple events coming in before checking the waiting condition, but in this
case we can just check the liveness of the channels.
2019-07-14 17:20:41 -05:00
Nathaniel Nicandro
8fc5f0bbee 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-30 12:22:26 -05:00
Nathaniel Nicandro
b40b7de837 Do not depend strongly on zmq
Having the `jupyter-comm-layer` abstraction means we do not need to do so.

* jupyter-base.el (zmq): Un-require.
(jupyter-socket-types): Move to `jupyter-channels.el`.
(jupyter-session): Don't mention zmq in doc string.
(jupyter-available-local-ports, jupyter-make-ssh-tunnel): New functions.
(jupyter-tunnel-connection): Use them.

* jupyter-channel-ioloop-comm.el: New file.

* jupyter-channels.el (jupyter-messages): Un-require.
(jupyter-comm-layer, zmq): New requires.
(jupyter-socket-types): Moved from `jupyter-base.el`.
(jupyter-send, jupyter-recv):
Implementations for `jupyter-session` moved from `jupyter-messages.el`.
(jupyter-sync-channel-comm): `jupyter-comm-layer` implementation for
`jupyter-sync-channel` objects moved from `jupyter-comm-layer.el`.

* jupyter-comm-layer.el (jupyter-channel-ioloop): Un-require.
(jupyter-sync-channel-comm): Move implementation to `jupyter-channels.el`.
(jupyter-ioloop-comm): Move implementation to new file `jupyter-ioloop-comm.el`.
(jupyter-channel-ioloop-comm):
Move implementation to new file `jupyter-channel-ioloop-comm.el`.

* jupyter-ioloop-comm.el: New file.

* jupyter-ioloop.el (zmq): Require.

* jupyter-kernel-manager.el
(jupyter-make-client): Ensure `jupyter-channel-ioloop-comm` is required.

* jupyter-messages.el (jupyter-send)
(jupyter-recv): Moved to `jupyter-channels.el`

* jupyter-repl.el
(jupyter-connect-repl): Ensure `jupyter-channel-ioloop-comm` is required.

* test/jupyter-test.el (jupyter-available-local-ports): New test.

* test/test-helper.el (jupyter-channel-ioloop-comm): New require.
2019-06-29 10:29:55 -05:00