##// END OF EJS Templates
completer not working fine
Omar Andres Zapata Mesa -
Show More
@@ -70,9 +70,10 b' class Frontend(object):'
70 self.msg_header = self.km.session.msg_header()
70 self.msg_header = self.km.session.msg_header()
71
71
72 self.completer = completer.ClientCompleter(self,self.session,self.request_socket)
72 self.completer = completer.ClientCompleter(self,self.session,self.request_socket)
73 rlcompleter.readline.parse_and_bind('tab: complete')
74 rlcompleter.readline.parse_and_bind('set show-all-if-ambiguous on')
75 rlcompleter.readline.set_completer(self.completer.complete)
73 rlcompleter.readline.set_completer(self.completer.complete)
74 rlcompleter.readline.parse_and_bind("tab: complete")
75 rlcompleter.readline.parse_and_bind('set show-all-if-ambiguous on')
76
76 history_path = os.path.expanduser('~/.ipython/history')
77 history_path = os.path.expanduser('~/.ipython/history')
77 if os.path.isfile(history_path):
78 if os.path.isfile(history_path):
78 rlcompleter.readline.read_history_file(history_path)
79 rlcompleter.readline.read_history_file(history_path)
@@ -131,27 +132,29 b' class Frontend(object):'
131
132
132 See parent class :meth:`execute` docstring for full details.
133 See parent class :meth:`execute` docstring for full details.
133 """
134 """
134 msg_id = self.km.xreq_channel.execute(source, hidden)
135 self.km.xreq_channel.execute(source, hidden)
135 #timer to debug
136 self.handle_xreq_channel()
136 time.sleep(0.5)
137
137 if self.km.xreq_channel.was_called():
138 def handle_xreq_channel(self):
138 self.msg_xreq = self.km.xreq_channel.get_msg()
139 # Give the kernel up to 0.5s to respond
139 print self.msg_xreq
140 for i in range(5):
140 if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] :
141 if self.km.xreq_channel.was_called():
141 if self.msg_xreq["content"]["status"] == 'ok' :
142 self.msg_xreq = self.km.xreq_channel.get_msg()
142 if self.msg_xreq["msg_type"] == "complete_reply" :
143 if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] :
143 print self.msg_xreq["content"]["matches"]
144 if self.msg_xreq["content"]["status"] == 'ok' :
145 if self.msg_xreq["msg_type"] == "complete_reply" :
146 print self.msg_xreq["content"]["matches"]
144
147
145 if self.msg_xreq["msg_type"] == "execute_reply" :
148 if self.msg_xreq["msg_type"] == "execute_reply" :
146 self.prompt_count = self.msg_xreq["content"]["execution_count"]
149 self.handle_sub_channel()
150 self.prompt_count = self.msg_xreq["content"]["execution_count"]
147
151
148 self.handle_sub_channel()
152 else:
149 else:
153 print >> sys.stderr, "Error executing: ",self.msg_xreq ##traceback no implemented yet here
150 print >> sys.stderr, "Error executing: ", source
154 print >> sys.stderr, "Status in the kernel: ", self.msg_xreq["content"]["status"]
151 print >> sys.stderr, "Status in the kernel: ", self.msg_xreq["content"]["status"]
155 break
152 #print msg_xreq
156 time.sleep(0.1)
153 else:
157
154 print >> sys.stderr, "Kernel is busy!"
155
158
156
159
157 def handle_sub_channel(self):
160 def handle_sub_channel(self):
@@ -18,10 +18,10 b' class SubSocketChannel2p(SubSocketChannel):'
18 self.queue.put(Message(msg))
18 self.queue.put(Message(msg))
19
19
20 def get_msg(self):
20 def get_msg(self):
21 return self.queue.get()
21 return self.queue.get(timeout=0.1)
22
22
23 def was_called(self):
23 def was_called(self):
24 return not self.queue.empty()
24 return self.queue.not_empty()
25
25
26 class XReqSocketChannel2p(XReqSocketChannel):
26 class XReqSocketChannel2p(XReqSocketChannel):
27 #---------------------------------------------------------------------------
27 #---------------------------------------------------------------------------
@@ -29,16 +29,15 b' class XReqSocketChannel2p(XReqSocketChannel):'
29 #---------------------------------------------------------------------------
29 #---------------------------------------------------------------------------
30 _msg = None
30 _msg = None
31 _called = False
31 _called = False
32 queue = Queue(-1)
32 def call_handlers(self, msg):
33 def call_handlers(self, msg):
33 self._called = True
34 self.queue.put(Message(msg))
34 self._msg = Message(msg)
35
35
36 def get_msg(self):
36 def get_msg(self):
37 self._called = False
37 return self.queue.get(timeout=0.1)
38 return self._msg
39
38
40 def was_called(self):
39 def was_called(self):
41 return self._called
40 return self.queue.not_empty()
42
41
43 class RepSocketChannel2p(RepSocketChannel):
42 class RepSocketChannel2p(RepSocketChannel):
44 #---------------------------------------------------------------------------
43 #---------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now