Commit graph

114 commits

Author SHA1 Message Date
Nathaniel Nicandro
62691611e4 Add jupyter--ioloop-collect-messages to simplify jupyter--ioloop even more 2018-01-11 12:04:42 -06:00
Nathaniel Nicandro
46b70e85d0 Refactor jupyter-initialize-connection
- Use `ignore-errors` around `jupyter-connection` slots since they can be
  inherited by the `parent-instance`. Note that checking if the slot is
  available does not also check if the slots availability in the
  `parent-instance`

- Set `addr` where it is used, namely in `cl-loop`
2018-01-11 00:26:03 -06:00
Nathaniel Nicandro
34b0d45078 Use quoted lists 2018-01-11 00:25:08 -06:00
Nathaniel Nicandro
56e5f047bd car instead of caar in jupyter--ioloop-queue-message
`elem` is a list not a list of lists
2018-01-11 00:22:19 -06:00
Nathaniel Nicandro
f705dc96fe Indentation 2018-01-09 00:44:35 -06:00
Nathaniel Nicandro
f3951ee9af Fix debug message 2018-01-09 00:44:35 -06:00
Nathaniel Nicandro
839e5d855a [WIP] Add ability to stop channels initially in jupyter-start-channels
Also add TODO about channel methods
2018-01-09 00:44:35 -06:00
Nathaniel Nicandro
a9f2bac2c8 Better logic on when to send queued messages in an ioloop subprocess 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
b198a02f45 Add note about how `jupyter-channel's are used in a client 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
912a367190 Error out when no ioloop process is present in jupyter-send 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
c358e37b23 Add missing initform 2018-01-09 00:44:34 -06:00
Nathaniel Nicandro
c7dee4aa55 Simplify kernel shutdown and interruptions in a kernel manager 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
7e36ea1101 Add jupyter-missing-request
This is a function which should be called on a `jupyter-kernel-client` and it
returns a request object which can be used to add callbacks to messages that
have no parent message such as the status: startup message sent be a kernel.
2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
7169c5072a warn instead of error when handling unknown message types 2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
44c75944d3 Fix missing argument 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
c706d07f02 Refactor jupyter--ioloop
Break it into several macros which perform various subtasks like processing a
command received from the parent emacs process and collecting messages into a
sorted list based on `jupyter-message-time`
2018-01-09 00:44:33 -06:00
Nathaniel Nicandro
b846af6c00 Remove unreachable code 2018-01-07 19:54:52 -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
f003e40101 Add more documentation 2018-01-07 14:06:14 -06:00
Nathaniel Nicandro
aff8f7dc5d Fix wrong number of arguments 2018-01-07 14:03:55 -06:00
Nathaniel Nicandro
ada66074f5 Fix some checkdoc warnings 2018-01-07 13:35:05 -06:00
Nathaniel Nicandro
b31aa780a3 Use cl-defgeneric for client handlers and requests methods
This way eldoc works with the method arguments
2018-01-06 22:50:55 -06:00
Nathaniel Nicandro
4896c6b75b Use pcase in jupyter--ioloop-filter
Also change the type of objects emitted by `jupyter--ioloop` to lists
2018-01-06 21:04:03 -06:00
Nathaniel Nicandro
f42a22c586 Update jupyter--ioloop to take into account changes in with-zmq-poller
Namely that `current-zmq-poller` is no longer available and the first argument of `with-zmq-poller` will be bound to a poller object.
2018-01-06 21:03:37 -06:00
Nathaniel Nicandro
3d78e2f00f Update comments and documentation 2018-01-06 19:56:54 -06:00
Nathaniel Nicandro
4944a5d75a Update callback interface
- Rename `jupyter-received-message-types` to `jupyter-message-types` and add
  message types for requests as well. Also change the keys to keywords instead
  of symbols. Using plists with keywords is in line with `jupyter-messages` and
  the arguments of the jupyter request functions.

- Rename `jupyter-request-run-callbacks` to `jupyter--run-callbacks`. This is
  more of an internal function so mark it as such.

- Change the order of the first two arguments in `jupyter-add-callback` and
  `jupyter-wait-until`. In both cases you are adding a callback to a request or
  waiting for some condition to be satisfied on the request not on the message
  type. This is also the reason why `jupyter-wait-until-received` keeps the
  message type as the first argument. We are waiting until a message of a
  certain type is received for a request, but the more important object in this
  case is the message type.

- Update other files to take into account these changes.
2018-01-06 19:55:46 -06:00
Nathaniel Nicandro
95dbc187eb Be consistent with how channels are initialized in jupyter-initialize-connection 2018-01-06 19:55:46 -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
Nathaniel Nicandro
cc3719dedd Rename jupyter-client-initialize-connection to jupyter-initialize-connection
Also update the documentation.
2018-01-06 19:55:45 -06:00
Nathaniel Nicandro
bf1b1dae42 Add jupyter-default-timeout variable 2018-01-06 19:55:45 -06:00
Nathaniel Nicandro
27c588ebf4 Use slot-value instead of eieio-oref 2018-01-06 19:55:45 -06:00
Nathaniel Nicandro
2d0ef56be6 Add more documentation, clean up comments 2018-01-06 19:55:45 -06:00
Nathaniel Nicandro
01dab0e403 Take into account changes in zmq-process-start
Namely that the process objects are not associated with any buffer.
2018-01-06 19:55:44 -06:00
Nathaniel Nicandro
3509cccbda Prioritize shell messages more than others
This avoids problems with a reply message and a status idle message being
received at identical times for a request. Two messages can be received at the
same time when the fractional seconds resolution of the time stamps received
from the kernel are not high enough. If the iopub channel had a higher priority
it would mean that the idle message would be received before the reply when
they have identical time stamps. Since request objects are removed from the
client when an idle message is received this would prevent any reply callbacks
from running.

To combat this problem, prioritize the shell messages over any other type of
message.
2018-01-06 19:55:44 -06:00
Nathaniel Nicandro
9dd45c6f3e Be consistent with how other channels are stopped
Specifically move the `jupyter-channel-alive-p` check into
`jupyter-stop-channel` for the heartbeat channel.
2018-01-06 19:54:40 -06:00
Nathaniel Nicandro
b1c96bd286 Only bind json variables when calling json-read-file 2018-01-06 19:54:40 -06:00
Nathaniel Nicandro
c143557fb9 Care more about the width of lines 2018-01-06 19:54:40 -06:00
Nathaniel Nicandro
bb55075080 Remove a redundant check of jupyter-request-idle-received-p 2018-01-06 19:54:36 -06:00
Nathaniel Nicandro
5ab0534eb4 Don't use cond as a variable name 2018-01-06 19:53:46 -06:00
Nathaniel Nicandro
bcaa7ef2d7 Add jupyter-request-inhibit-handlers for convenience 2018-01-06 19:53:46 -06:00
Nathaniel Nicandro
068f09fa9e Update callback interface
- Introduce `run-handlers-p` for `jupyter-request` objects. When this field is
  non-nil, a clients `jupyter-handle-message` method will pass the message to
  the channels `jupyter-handle-message` after running any callbacks. Otherwise
  the channel handlers will not be run. This gives a way to suppress the
  channel handlers for a request.

- Also remove the use of `jupyter-callback` since `jupyter-handle-message` for
  a client just removes requests when an idle message is received. The callback
  object was used to check if a callback actually ran.
2018-01-06 19:47:47 -06:00
Nathaniel Nicandro
3c8cfee3ac Introduce the jupyter-handle-message method
This method dispatches to the appropriate message handlers based on the type of
channel passed to `jupyter-handle-message`. This method is also defined for a
`jupyter-kernel-client` in which case any callbacks for a message will be run
and then the message passed to the channel handlers.
2018-01-06 19:43:21 -06:00
Nathaniel Nicandro
bf81372d7a Update documentation of jupyter-wait-until-idle 2018-01-06 19:27:01 -06:00
Nathaniel Nicandro
745c08f0f6 Use with-timeout in jupyter-wait-until 2018-01-06 19:27:01 -06:00
Nathaniel Nicandro
bfb4f335c8 Cleanup comments, fix indentation, fix argument name 2018-01-06 19:27:01 -06:00