Show More
@@ -194,6 +194,7 b' class ShellChannel(ZMQSocketChannel):' | |||||
194 | 'history', |
|
194 | 'history', | |
195 | 'kernel_info', |
|
195 | 'kernel_info', | |
196 | 'shutdown', |
|
196 | 'shutdown', | |
|
197 | 'is_complete', | |||
197 | ] |
|
198 | ] | |
198 |
|
199 | |||
199 | def __init__(self, context, session, address): |
|
200 | def __init__(self, context, session, address): | |
@@ -396,6 +397,10 b' class ShellChannel(ZMQSocketChannel):' | |||||
396 | self._queue_send(msg) |
|
397 | self._queue_send(msg) | |
397 | return msg['header']['msg_id'] |
|
398 | return msg['header']['msg_id'] | |
398 |
|
399 | |||
|
400 | def is_complete(self, code): | |||
|
401 | msg = self.session.msg('is_complete_request', {'code': code}) | |||
|
402 | self._queue_send(msg) | |||
|
403 | return msg['header']['msg_id'] | |||
399 |
|
404 | |||
400 |
|
405 | |||
401 | class IOPubChannel(ZMQSocketChannel): |
|
406 | class IOPubChannel(ZMQSocketChannel): |
@@ -160,6 +160,10 b' class KernelInfoReply(Reference):' | |||||
160 | banner = Unicode() |
|
160 | banner = Unicode() | |
161 |
|
161 | |||
162 |
|
162 | |||
|
163 | class IsCompleteReply(Reference): | |||
|
164 | complete = Bool() | |||
|
165 | ||||
|
166 | ||||
163 | # IOPub messages |
|
167 | # IOPub messages | |
164 |
|
168 | |||
165 | class ExecuteInput(Reference): |
|
169 | class ExecuteInput(Reference): | |
@@ -189,6 +193,7 b' references = {' | |||||
189 | 'status' : Status(), |
|
193 | 'status' : Status(), | |
190 | 'complete_reply' : CompleteReply(), |
|
194 | 'complete_reply' : CompleteReply(), | |
191 | 'kernel_info_reply': KernelInfoReply(), |
|
195 | 'kernel_info_reply': KernelInfoReply(), | |
|
196 | 'is_complete_reply': IsCompleteReply(), | |||
192 | 'execute_input' : ExecuteInput(), |
|
197 | 'execute_input' : ExecuteInput(), | |
193 | 'execute_result' : ExecuteResult(), |
|
198 | 'execute_result' : ExecuteResult(), | |
194 | 'error' : Error(), |
|
199 | 'error' : Error(), | |
@@ -382,6 +387,12 b' def test_single_payload():' | |||||
382 | next_input_pls = [pl for pl in payload if pl["source"] == "set_next_input"] |
|
387 | next_input_pls = [pl for pl in payload if pl["source"] == "set_next_input"] | |
383 | nt.assert_equal(len(next_input_pls), 1) |
|
388 | nt.assert_equal(len(next_input_pls), 1) | |
384 |
|
389 | |||
|
390 | def test_is_complete(): | |||
|
391 | flush_channels() | |||
|
392 | ||||
|
393 | msg_id = KC.is_complete("a = 1") | |||
|
394 | reply = KC.get_shell_msg(timeout=TIMEOUT) | |||
|
395 | validate_message(reply, 'is_complete_reply', msg_id) | |||
385 |
|
396 | |||
386 | # IOPub channel |
|
397 | # IOPub channel | |
387 |
|
398 |
@@ -114,7 +114,7 b' class Kernel(Configurable):' | |||||
114 | 'inspect_request', 'history_request', |
|
114 | 'inspect_request', 'history_request', | |
115 | 'kernel_info_request', |
|
115 | 'kernel_info_request', | |
116 | 'connect_request', 'shutdown_request', |
|
116 | 'connect_request', 'shutdown_request', | |
117 | 'apply_request', |
|
117 | 'apply_request', 'is_complete_request', | |
118 | ] |
|
118 | ] | |
119 | self.shell_handlers = {} |
|
119 | self.shell_handlers = {} | |
120 | for msg_type in msg_types: |
|
120 | for msg_type in msg_types: | |
@@ -479,6 +479,22 b' class Kernel(Configurable):' | |||||
479 | kernel. |
|
479 | kernel. | |
480 | """ |
|
480 | """ | |
481 | return {'status': 'ok', 'restart': restart} |
|
481 | return {'status': 'ok', 'restart': restart} | |
|
482 | ||||
|
483 | def is_complete_request(self, stream, ident, parent): | |||
|
484 | content = parent['content'] | |||
|
485 | code = content['code'] | |||
|
486 | ||||
|
487 | reply_content = self.do_is_complete(code) | |||
|
488 | reply_content = json_clean(reply_content) | |||
|
489 | reply_msg = self.session.send(stream, 'is_complete_reply', | |||
|
490 | reply_content, parent, ident) | |||
|
491 | self.log.debug("%s", reply_msg) | |||
|
492 | ||||
|
493 | def do_is_complete(self, code): | |||
|
494 | """Override in subclasses to find completions. | |||
|
495 | """ | |||
|
496 | return {'complete' : True, | |||
|
497 | } | |||
482 |
|
498 | |||
483 | #--------------------------------------------------------------------------- |
|
499 | #--------------------------------------------------------------------------- | |
484 | # Engine methods |
|
500 | # Engine methods |
General Comments 0
You need to be logged in to leave comments.
Login now