Commit graph

62 commits

Author SHA1 Message Date
Nathaniel Nicandro
83af335166
Bump version 2019-03-14 09:29:11 -05:00
Nathaniel Nicandro
662e983612
Don't require subr-x at runtime 2019-03-14 09:16:44 -05:00
Nathaniel Nicandro
d4969cbfcc CHANGELOG.org: Add function to change version numbers 2019-02-14 23:05:00 -06:00
Nathaniel Nicandro
e8715a9e57
jupyter-hb-pause: Empty the socket's message queue
This is needed to avoid an invalid state of the socket when un-pausing the
channel and attempting to send a message when there is a message waiting to be
received.
2019-02-12 14:53:56 -06:00
Nathaniel Nicandro
63717b9e39
Bump version 2019-02-12 09:17:06 -06:00
Nathaniel Nicandro
771e267034
Fix checkdoc errors 2019-02-06 22:49:41 -06:00
Nathaniel Nicandro
1054dc8857
Use when-let* 2019-01-22 12:14:32 -06:00
Nathaniel Nicandro
081f329da1 v0.6.0 2018-11-16 00:27:47 -06:00
Nathaniel Nicandro
823ea8adde Fix checkdoc warnings 2018-11-15 23:04:27 -06:00
Nathaniel Nicandro
1fa522a4cd Simplify heartbeat channel logic 2018-11-15 23:04:27 -06:00
Nathaniel Nicandro
10d1e18ffa jupyter-hb--send-ping: Refactor for readability 2018-11-13 17:47:55 -06:00
Nathaniel Nicandro
84695e98d0 jupyter-start-channel: Don't un-pause the heartbeat channel
Starting a channel means that it is open for communication. It is already
un-paused by jupyter-start-new-kernel, so it is ok to make this change here.
2018-11-13 17:46:19 -06:00
Nathaniel Nicandro
d083ff5746 jupyter-hb-unpause: Simplify 2018-11-13 17:46:19 -06:00
Nathaniel Nicandro
19868e3ec9 Use jupyter-channel-alive-p instead of testing socket directly
* jupyter-channels (jupyter-hb-pause, jupyter-channel--reset-socket): Do it.
(jupyter-start-channel): Always reset the socket.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
6942a20e8a Add new jupyter-ioloop implementation
A `jupyter-kernel-client' defers most of its message sending, receiving, and
message processing to a subprocess which sends its messages to the kernel
through zmq sockets and polls for any messages to received from the kernel.
This commit generalizes this by introducing a new `jupyter-ioloop` type which
encapsulates the subprocess and the code necessary to build up the function
that does the work of communicating with a kernel in the subprocess
environment.

* jupyter-channels.el: Remove `jupyter-async-channel`

* jupyter-ioloop.el: New file.
(jupyter-ioloop-poller):
(jupyter-ioloop-nsockets):
(jupyter-ioloop-pre-hook):
(jupyter-ioloop-post-hook):
(jupyter-ioloop--argument-types): New variables.
(jupyter-ioloop): New function to create `jupyter-ioloop` objects.
(jupyter-ioloop-add-setup):
(jupyter-ioloop-add-teardown):
(jupyter-ioloop-add-arg-type):
(jupyter-ioloop-add-event): New macros.
(jupyter-ioloop-handler):
(jupyter-ioloop-add-callback):
(jupyter-ioloop-start):
(jupyter-ioloop-stop): New methods.
(jupyter-send): Method addition for `jupyter-ioloop` objects.
(jupyter-ioloop-wait-until): Moved function from `jupyter-client.el`, changed
argument order.
(jupyter-ioloop--replace-args):
(jupyter-ioloop--event-dispatcher):
(jupyter-ioloop--function):
(jupyter-ioloop--filter):
(jupyter-ioloop--sentinel): Helper functions.

* jupyter-client.el: Add `jupyter-ioloop` require.
Remove `jupyter-shell-channel`, `jupyter-iopub-channel`,
`jupyter-stdin-channel` classes.
(jupyter-kernel-client): Change type of `ioloop` slot to `jupyter-ioloop`,
remove `shell-channel`, iopub-channel`, `stdin-channel`, and `hb-channel`
slots. Add `channels` slot.
(jupyter-initialize-connection): Replace channel initialization with
initialization of new `channels` slot.
(jupyter-send): Add better assertion. Call an ioloop's `jupyter-send` method.
Expect a Jupyter channel keyword as the `channel` argument.
(jupyter--ioloop-do-command):
(jupyter--ioloop-with-lock-file):
(jupyter--ioloop-unlock):
(jupyter--ioloop-lock):
(jupyter--ioloop):
(jupyter--ioloop-sentinel):
(jupyter--get-channel):
(jupyter--ioloop-filter):
(jupyter--start-ioloop): Remove functions/macros.
(jupyter-ioloop-wait-until): Move to `jupyter-ioloop.el`
(jupyter-hb-pause):
(jupyter-hb-unpause):
(jupyter-hb-beating-p): Use `channels` slot.
(jupyter-client--ioloop-setup-form): New constant.
(jupyter-ioloop-add-arg-type): New jupyter-channel argument type.
(jupyter-ioloop-add-start-channel-event):
(jupyter-ioloop-add-stop-channel-event):
(jupyter-ioloop-add-send-event): New `jupyter-ioloop` event types for clients.
(jupyter-ioloop-start):
(jupyter-ioloop-handler): Method additions specializing to
`jupyter-kernel-client`s.
(jupyter-start-channel):
(jupyter-stop-channel):
(jupyter-channel-alive-p): Method additions for a client utilizing `channels` slot.
(jupyter-start-channels):
(jupyter-stop-channels):
(jupyter-channels-running-p): Use new `jupyter-ioloop` interface and channel
methods.
(jupyter-handle-message): (`jupyter-kernel-client` method) Add new `msg`
argument. Remove call to `jupyter-get-message`.
(jupyter-handle-message): (All channel methods) Replace
`jupyter-stdin-channel`, `jupyter-iopub-channel`, and `jupyter-shell-channel`
with `(eql :stdin)`, `(eql :iopub)`, and `(eql :shell)`
(jupyter-handle-input-request):
(jupyter-send-execute-request):
(jupyter-send-inspect-request):
(jupyter-send-complete-request):
(jupyter-send-history-request):
(jupyter-send-is-complete-request):
(jupyter-send-comm-info-request):
(jupyter-send-comm-open):
(jupyter-send-comm-msg):
(jupyter-send-comm-close):
(jupyter-sned-kernel-info-request):
(jupyter-send-shutdown-request): Remove uses of `shell-channel` and
`stdin-channel` slot. Pass in expected channel keyword as the `channel`
argument in the call to `jupyter-send`
2018-11-13 17:46:03 -06:00
Nathaniel Nicandro
348541dfe7 Update documentation and commentary 2018-11-08 21:30:32 -06:00
Nathaniel Nicandro
becddfc9ea Fix requires
`jupyter-channels.el` depends on the `jupyter-send` method defined in
`jupyter-messages.el` whereas `jupyter-messages.el` does not depend on any
functions in `jupyter-channels.el`.

* jupyter-channel.el: Require `jupyter-messages`

* jupyter-messages.el: Remove `jupyter-channels` require
2018-11-08 21:30:32 -06:00
Nathaniel Nicandro
527c2ae859 Fix wrong variable name 2018-11-05 00:00:11 -06:00
Nathaniel Nicandro
8badade6d1 jupyter-hb-unpause: Set paused to nil when sending a ping is guaranteed 2018-11-01 01:56:59 -05:00
Nathaniel Nicandro
e929cffba1 jupyter-stop-channel: Group oref calls 2018-11-01 01:56:59 -05:00
Nathaniel Nicandro
2e97d8ce01 Remove code duplication when connecting heartbeat channels
* Add `jupyter-channel--reset-socket` which does the work of connecting the
  heartbeat channel to its endpoint and takes care of possibly reseting the
  socket after sending a ping.
2018-11-01 01:56:58 -05:00
Nathaniel Nicandro
e02bed9a50 Add jupyter-hb-consider-dead-periods 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
288fb17ece Update comments 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
f0fe7ff5e8 Document the status slot of jupyter-async-channel 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
ceed853658 Convert jupyter-hb-on-kernel-dead to a method 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
b6428b441f Fix the heartbeat channel implementation
* Actually set the paused slot to nil when un-pausing the
  heartbeat channel

* Ensure the heartbeat socket is actually a socket when
  receiving. This is to handle edge cases when the
  heartbeat channel is stopped, but there still is a timer
  left in the `timer-list`.
2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
276c02cfce Add more documentation 2018-10-25 23:07:46 -05:00
Nathaniel Nicandro
c070f2d04d Update documentation and comments 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
26b9f90feb Simplify heartbeat channel logic 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
554e519bf0 Avoid delays during message processing
- Allow specifying a msg-id before a call to `jupyter-send`

  - This avoid sending a message to the browser displaying the widgets on every
    message send to the kernel. The previous implementation generated a new ID
    without allowing the caller to pass one in.

- Simplify message polling by sending received messages from the kernel to the
  parent Emacs process at the moment of arrival.
2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
12c4b61d88 Send the endpoint and identity to the subprocess when starting async channels 2018-05-15 16:45:24 -05:00
Nathaniel Nicandro
fc665655f8 Remove jupyter-connection
To make up for this:
- Move the functions defined in `jupyter-connection.el` to `jupyter-base.el`
- Add a `session` field to the `jupyter-kernel-manager` and `jupyter-channel`
  classes
- Add a `kernel-info` field to the `jupyter-repl-client`
- Add a `conn-info` field to a `jupyter-session`
- Add a `session` field to `jupyter-kernel-client`
2018-05-15 16:45:24 -05:00
Nathaniel Nicandro
bcd45b6db4 Tiny refactors/optimizations 2018-05-13 12:11:08 -05:00
Nathaniel Nicandro
f79c0b68ac Update ZMQ calls for an updated version of ZMQ 2018-05-06 03:15:42 -05:00
Nathaniel Nicandro
98c646bfb5 Block until a channel is stopped in jupyter-stop-channel for async channels 2018-02-12 10:22:13 -06:00
Nathaniel Nicandro
2cb665e744 Check if the ioloop process is live in jupyter-channel-alive-p for async channels 2018-02-04 18:10:32 -06:00
Nathaniel Nicandro
e6d9fcbf5a Add kernel-died-cb for heartbeat channels
This is a callback function which is called when no response has been received
from the kernel after 5 `time-to-dead` periods.
2018-02-04 18:08:05 -06:00
Nathaniel Nicandro
290f3a2d96 Block until channel is alive in jupyter-start-channel for async channels 2018-02-04 17:43:20 -06:00
Nathaniel Nicandro
43a59ba74d Update channel implementation
- Distinguish between an asynchronous channel and a synchronous one

  - `jupyter-async-channel` :: Messages are sent and received through an ioloop
                               subprocess that the channel has access to. The
                               subprocess uses the `jupyter-sync-channel` for
                               sending and receiving messages.

  - `jupyter-sync-channel` :: Messages are sent and received through a
                               `zmq-socket` in the current Emacs session.

  - Define `jupyter-send` and `jupyter-recv` methods for channels.

  - Update `jupyter-kernel-client` and ioloop interfaces to take into account
    changes with channels.
2018-02-03 19:06:10 -06:00
Nathaniel Nicandro
5763aa3beb Cleanup/add more documentation for jupyter-channels 2018-01-22 18:48:20 -06:00
Nathaniel Nicandro
1d024d54cc Handle signal interrupts in the heartbeat channel 2018-01-16 11:52:59 -06:00
Nathaniel Nicandro
047968c4e9 Refactor jupyter-start-channel 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
a7539dc37b Fix checkdoc warnings 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
9ba6ad331e Remove uses of lexical-let 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
326ff15d92 Add standard header comments 2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
ebd616998e Add/update lots of documentation 2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
f904dc7d2a Rename jupyter-push-message -> jupyter-queue-message 2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
71c4314a86 jupyter-connection inherits from eieio-instance-inheritor
This way when creating kernel clients with `jupyter-kernel-manager`, we can set
the `parent-instance` of the newly created client to the manager thereby
inheriting the `jupyter-session` from the kernel manager.

Also have `jupyter-channel` objects inherit from a `jupyter-connection` so that
we can define `jupyter-send` and `jupyter-recv` methods for channels in the future.
2018-01-07 14:53:12 -06:00
Nathaniel Nicandro
cfdf68eb43 Remove channel in some jupyter-channel method names 2018-01-06 19:55:46 -06:00
Nathaniel Nicandro
b3b1066624 Re-organization of code base
- `jupyter-client.el` only contains client related code

- `jupyter-kernel-manager` related code is placed in `jupyter-kernel-manager.el`

- Socket creating functions and generating connection info plist function are
  placed in `jupyter-connection.el`. This also contains the
  `jupyter-connection` class.

- Kernelspec related functions are placed in `jupyter-kernelspec.el`

- Move general utility functions and variables requires necessary for `jupyter`
  into `jupyter-base.el`. This also contains the `jupyter-session` and
  `jupyter-request` struct definitions.
2018-01-06 19:55:45 -06:00