Show More
@@ -2,14 +2,21 b'' | |||
|
2 | 2 | import readline |
|
3 | 3 | from Queue import Empty |
|
4 | 4 | |
|
5 | class ZMQCompleter(object): | |
|
5 | from IPython.config import Configurable | |
|
6 | from IPython.utils.traitlets import Float | |
|
7 | ||
|
8 | class ZMQCompleter(Configurable): | |
|
6 | 9 | """Client-side completion machinery. |
|
7 | 10 | |
|
8 | 11 | How it works: self.complete will be called multiple times, with |
|
9 | 12 | state=0,1,2,... When state=0 it should compute ALL the completion matches, |
|
10 | 13 | and then return them for each value of state.""" |
|
14 | ||
|
15 | timeout = Float(5.0, config=True, help='timeout before completion abort') | |
|
11 | 16 | |
|
12 | def __init__(self, shell, client): | |
|
17 | def __init__(self, shell, client, config=None): | |
|
18 | super(ZMQCompleter,self).__init__(config=config) | |
|
19 | ||
|
13 | 20 | self.shell = shell |
|
14 | 21 | self.client = client |
|
15 | 22 | self.matches = [] |
@@ -23,7 +30,7 b' class ZMQCompleter(object):' | |||
|
23 | 30 | msg_id = self.client.shell_channel.complete(text=text, line=line, |
|
24 | 31 | cursor_pos=cursor_pos) |
|
25 | 32 | |
|
26 |
msg = self.client.shell_channel.get_msg(timeout= |
|
|
33 | msg = self.client.shell_channel.get_msg(timeout=self.timeout) | |
|
27 | 34 | if msg['parent_header']['msg_id'] == msg_id: |
|
28 | 35 | return msg["content"]["matches"] |
|
29 | 36 | return [] |
@@ -33,7 +40,8 b' class ZMQCompleter(object):' | |||
|
33 | 40 | try: |
|
34 | 41 | self.matches = self.complete_request(text) |
|
35 | 42 | except Empty: |
|
36 | print('WARNING: Kernel timeout on tab completion.') | |
|
43 | #print('WARNING: Kernel timeout on tab completion.') | |
|
44 | pass | |
|
37 | 45 | |
|
38 | 46 | try: |
|
39 | 47 | return self.matches[state] |
@@ -118,7 +118,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||
|
118 | 118 | from IPython.core.completerlib import (module_completer, |
|
119 | 119 | magic_run_completer, cd_completer) |
|
120 | 120 | |
|
121 | self.Completer = ZMQCompleter(self, self.client) | |
|
121 | self.Completer = ZMQCompleter(self, self.client, config=self.config) | |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | self.set_hook('complete_command', module_completer, str_key = 'import') |
General Comments 0
You need to be logged in to leave comments.
Login now