Commit graph

125 commits

Author SHA1 Message Date
Nathaniel Nicandro
3d45427eee jupyter-start-kernel: Use with-temp-file 2018-11-13 18:17:44 -06:00
Nathaniel Nicandro
9309e6c477 jupyter-start-channels: Simplify kernel manager method
* jupyter-kernel-manager: (jupyter-start-channels): Do it.
2018-11-13 18:17:44 -06:00
Nathaniel Nicandro
ff2feaab69 jupyter-shutdown-kernel: Report progress when shutting down 2018-11-13 17:47:55 -06:00
Nathaniel Nicandro
9aff88331a jupyter-start-new-kernel: Simplify
Remove the need to wrap in a progn. Un-pause heartbeat after waiting so that we
know for sure the kernel can be communicated with.
2018-11-13 17:47:55 -06:00
Nathaniel Nicandro
a82ae13438 Add jupyter-with-timeout macro
* jupyter-base.el (jupyter-default-timeout)
(jupyter-long-timeout): Moved from jupyter-client.el
(jupyter-with-timeout): Do it.

* jupyter-client.el (jupyter-wait-until): Use it.

* jupyter-kernel-manager.el (jupyter-shutdown-kernel)
(jupyter-interrupt-kernel, jupyter-start-new-kernel):
(jupyter-start-kernel): Use it.

use timeout
2018-11-13 17:46:19 -06:00
Nathaniel Nicandro
af32a3352f Promote the execution-state to be a slot of jupyter-kernel-client
* jupyter-client.el (jupyter-kernel-client): Do it.
(jupyter-run-hook-with-args-until-success): Pass client as first argument to
hooks.
(jupyter-execution-state): New convenience function.
(jupyter--set-execution-state): New helper function. Add as global IOPUB
message hook to set the execution-state slot.

* jupyter-repl.el (jupyter-repl-client): Remove execution-state slot.
(jupyter-handle-status): Don't set the execution-state slot.
(jupyter-repl-ret, jupyter-repl-interaction-mode-line): Use
jupyter-execution-state.
(jupyter-repl-initialize-hooks): Take into account changes to message hooks.

* jupyter-kernel-manager (jupyter-start-new-kernel): Update callback.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
2ae44ebcd6 jupyter--kernel-sentinel: Kill the process buffer when the kernel process is dead 2018-11-01 01:56:58 -05:00
Nathaniel Nicandro
91e766ed27 jupyter--kernel-sentinel: Use with-slots 2018-11-01 01:56:58 -05:00
Nathaniel Nicandro
890f5ab3cb Silence byte compiler
* Declare undeclared external functions

* Add ext: prefix to filename of external packages that may not be present on
  every system

* Remove `company-grab-symbol-cons` function declaration since this function is
  no longer used.
2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
2f3f910598 Replace deprecated destructor method with jupyter-finalizer 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
673747dc03 Add kill-emacs-hook functions for cleaning up clients and managers
If `kill-emacs` is called while the kernel process or client channel processes
are still alive, the process sentinels do not run and thus the cleanup of the
clients and managers does not happen. Thus we need to explicitly do this
cleanup when `kill-emacs` is called.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c51d3b3a6c jupyter-start-kernel: Remove ANSI color codes in process output 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
6d3b326124 jupyter-shutdown-kernel: Fix wording of documentation 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
883197074e Move the kernel-info slot of jupyter-repl-client' to jupyter-kernel-client'
* Define new method `jupyter-kernel-info` which takes care
  of caching the result of a kernel info request. All
  access of the kernel info plist should happen through
  this method.

* Do not return the kernel info plist in
  `jupyter-start-new-kernel`, callers should access the
  kernel info through `jupyter-kernel-info`
2018-10-25 22:57:33 -05:00
Nathaniel Nicandro
c070f2d04d Update documentation and comments 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
c7c50f4908 Better error reporting when the kernel process dies in jupyter-start-kernel 2018-08-30 18:02:25 -05:00
Nathaniel Nicandro
22b1e809a0 Update documentation, cleanup comments 2018-08-30 18:02:13 -05:00
Nathaniel Nicandro
6e68a622cd Handle edge cases when starting a kernel and killing a REPL buffer
- Kill the REPL buffer without asking when the channels are closed

- Only emit a message if the kernel does not respond to a startup message
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
436089d08b Prefer defun over defsubst and other miscellaneous changes
- Add missing namespace to sha256 function

  - Any function defined should have a `jupyter-` prefix

- Remove `cl-lib` dependency in `jupyter-messages.el`

- Include `subr-x` in `jupyter-base.el`

- Use `tramp-file-name-user` instead of `tramp-file-name-real-user` since the
  latter is missing in Emacs 26
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
17596ee1c4 Be less ambiguous when encoding/decoding messages
- Do not handle nil as an empty dictionary when encoding.

- Use the default `json-array-type`
2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
2f83bfd3ae Use jupyter-message-status-starting-p where appropriate 2018-05-20 11:03:06 -05:00
Nathaniel Nicandro
ccf3633604 Do not rename the connection file after is has been used to start a kernel 2018-05-20 11:02:24 -05:00
Nathaniel Nicandro
94171eba4a Update documentation 2018-05-16 21:54:29 -05:00
Nathaniel Nicandro
1841e49b5d Be consistent with message types
Only use the message symbol's as defined in `jupyter-message-types` and switch
to the string representation only when sending a message.
2018-05-16 20:46:10 -05:00
Nathaniel Nicandro
3b3fe9c43f jupyter-<type> -> jupyter-send-<type> where appropriate 2018-05-16 12:25:57 -05:00
Nathaniel Nicandro
670611ded1 Update code comments and documentation 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
ef69521202 Update documentation and comments 2018-02-12 11:06:09 -06:00
Nathaniel Nicandro
86be51eb72 Don't rely on the event string in a process sentinel 2018-02-09 17:23:46 -06:00
Nathaniel Nicandro
83881bf4e0 Ensure the startup message is caught
Setup the necessary hooks before starting the kernel so that we can ensure that
the startup message is caught.

A short delay is also added whenever we start a channel. This was necessary for
the client to catch the startup message of a python kernel.
2018-02-07 12:08:07 -06:00
Nathaniel Nicandro
aa054178b7 Refactor jupyter-start-new-kernel 2018-02-03 19:06:10 -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
0504bf36e0 Update documentation and comments 2018-02-03 19:06:10 -06:00
Nathaniel Nicandro
341214f5a9 Add documentation 2018-01-22 19:21:44 -06:00
Nathaniel Nicandro
51e48545a6 Fix use of progress reporter 2018-01-22 18:36:00 -06:00
Nathaniel Nicandro
c7a4874222 Only attempt to start a kernel when it is not already started 2018-01-22 18:35:25 -06:00
Nathaniel Nicandro
d41751575a Re-emit error when kernel fails to start 2018-01-21 01:06:29 -06:00
Nathaniel Nicandro
7267577de0 Take into account changes in kernelspec code 2018-01-20 23:13:04 -06:00
Nathaniel Nicandro
43d5d4a8c9 Use cl-defgeneric for jupyter-kernel-manager methods
Also cleanup documentation
2018-01-18 23:00:31 -06:00
Nathaniel Nicandro
6934118012 Add progress reporters when starting a kernel 2018-01-18 22:47:18 -06:00
Nathaniel Nicandro
de635fdc3a Add customizable jupyter-runtime-directory variable
- Also fix the handling of `resource_dir` in a kernelspec argument vector
2018-01-18 22:45:17 -06:00
Nathaniel Nicandro
f27fad472b Add documentation to jupyter-kernel-manager slots 2018-01-18 22:43:52 -06:00
Nathaniel Nicandro
fc052d3baf jupyter-connection objects have a kernel-info slot
This allows the kernel info to be shared between a kernel manager and the
clients that have the manager as its parent instance.
2018-01-18 21:14:27 -06:00
Nathaniel Nicandro
e457ecbfa7 Add object destructors for jupyter-kernel-manager and jupyter-kernel-client
These are used when an object definately needs to be destroyed. They are needed
to cleanup resources like processes and internal buffers.
2018-01-18 16:06:22 -06:00
Nathaniel Nicandro
d0257740bb Simplify variable names 2018-01-17 20:37:34 -06:00
Nathaniel Nicandro
e4c3088749 Add jupyter-inhibit-handlers
This removes the need for `jupyter-request-inhibit-handlers`
2018-01-17 20:34:32 -06:00
Nathaniel Nicandro
f302445ac2 Handle more failure cases when starting a new kernel 2018-01-16 11:52:26 -06:00
Nathaniel Nicandro
9b66532f94 Use message instead of warn 2018-01-16 11:52:10 -06:00
Nathaniel Nicandro
5864e855e3 Add a buffer to the kernel process
This allows for looking at the kernel stdout
2018-01-16 11:51:16 -06:00