##// END OF EJS Templates
Merge pull request #3769 from Carreau/fxcpl...
Matthias Bussonnier -
r11687:d1a85012 merge
parent child Browse files
Show More
@@ -2,14 +2,21 b''
2 import readline
2 import readline
3 from Queue import Empty
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 """Client-side completion machinery.
9 """Client-side completion machinery.
7
10
8 How it works: self.complete will be called multiple times, with
11 How it works: self.complete will be called multiple times, with
9 state=0,1,2,... When state=0 it should compute ALL the completion matches,
12 state=0,1,2,... When state=0 it should compute ALL the completion matches,
10 and then return them for each value of state."""
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 self.shell = shell
20 self.shell = shell
14 self.client = client
21 self.client = client
15 self.matches = []
22 self.matches = []
@@ -23,7 +30,7 b' class ZMQCompleter(object):'
23 msg_id = self.client.shell_channel.complete(text=text, line=line,
30 msg_id = self.client.shell_channel.complete(text=text, line=line,
24 cursor_pos=cursor_pos)
31 cursor_pos=cursor_pos)
25
32
26 msg = self.client.shell_channel.get_msg(timeout=0.5)
33 msg = self.client.shell_channel.get_msg(timeout=self.timeout)
27 if msg['parent_header']['msg_id'] == msg_id:
34 if msg['parent_header']['msg_id'] == msg_id:
28 return msg["content"]["matches"]
35 return msg["content"]["matches"]
29 return []
36 return []
@@ -33,7 +40,8 b' class ZMQCompleter(object):'
33 try:
40 try:
34 self.matches = self.complete_request(text)
41 self.matches = self.complete_request(text)
35 except Empty:
42 except Empty:
36 print('WARNING: Kernel timeout on tab completion.')
43 #print('WARNING: Kernel timeout on tab completion.')
44 pass
37
45
38 try:
46 try:
39 return self.matches[state]
47 return self.matches[state]
@@ -118,7 +118,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
118 from IPython.core.completerlib import (module_completer,
118 from IPython.core.completerlib import (module_completer,
119 magic_run_completer, cd_completer)
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 self.set_hook('complete_command', module_completer, str_key = 'import')
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