##// END OF EJS Templates
Minor tidy up of zmqterminal.completer
Thomas Kluyver -
Show More
@@ -3,6 +3,10 b' import readline'
3 3 import time
4 4 import sys
5 5 stdout = sys.stdout
6
7 class TimeoutError(Exception):
8 pass
9
6 10 class ClientCompleter2p(object):
7 11 """Client-side completion machinery.
8 12
@@ -23,30 +27,25 b' class ClientCompleter2p(object):'
23 27 dict(text=text, line=line))
24 28 # send completion request to kernel
25 29 # Give the kernel up to 0.5s to respond
26 msg_matches = None
27 30 for i in range(5):
28 if self.km.xreq_channel.was_called():
29 msg_xreq = self.km.xreq_channel.get_msg()
30 if msg["header"]['session'] == msg_xreq["parent_header"]['session'] :
31 if msg_xreq["content"]["status"] == 'ok' :
32 if msg_xreq["msg_type"] == "complete_reply" :
33 msg_matches = msg_xreq["content"]["matches"]
34 #break
35 time.sleep(0.1)
36 return msg_matches
31 if self.km.xreq_channel.was_called():
32 msg_xreq = self.km.xreq_channel.get_msg()
33 if msg["header"]['session'] == msg_xreq["parent_header"]['session'] and \
34 msg_xreq["content"]["status"] == 'ok' and \
35 msg_xreq["msg_type"] == "complete_reply" :
36 return msg_xreq["content"]["matches"]
37
38 time.sleep(0.1)
39 raise TimeoutError
37 40
38 41 def complete(self, text, state):
39 if state == 0 :
40 self.matches = self.complete_request(text)
41
42 if self.matches is None:
43 self.matches = []
44 print('WARNING: Kernel timeout on tab completion.')
45 #print self.matches
42 if state == 0:
43 try:
44 self.matches = self.complete_request(text)
45 except TimeoutError:
46 print('WARNING: Kernel timeout on tab completion.')
47
46 48 try:
47 49 return self.matches[state]
48 50 except IndexError:
49 51 return None
50
51
52
General Comments 0
You need to be logged in to leave comments. Login now