##// END OF EJS Templates
eliminate hardcoded wait, now wait on outputs...
eliminate hardcoded wait, now wait on outputs Note: this test still sometimes fails, though I don't understand why. Increasing the wait time to 30 seconds does not help, which leads me to believe that there's some race condition, or that we're genuinely dropping outputs sometimes (saved notebooks on these timeouts *do* contain an In[] number, but don't have any outputs attached). @ellisonbg and @minrk might now what's going on with that. To run just this test, fire up a notebook server on port 8888 and run: while true; do casperjs test --includes=util.js test_cases/execute_code_cell.js ; done

File last commit:

r11676:c32a3259
r13277:8cc2a54f
Show More
completer.py
52 lines | 1.7 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
import readline
from Queue import Empty
from IPython.config import Configurable
from IPython.utils.traitlets import Float
class ZMQCompleter(Configurable):
"""Client-side completion machinery.
How it works: self.complete will be called multiple times, with
state=0,1,2,... When state=0 it should compute ALL the completion matches,
and then return them for each value of state."""
timeout = Float(5.0, config=True, help='timeout before completion abort')
def __init__(self, shell, client, config=None):
super(ZMQCompleter,self).__init__(config=config)
self.shell = shell
self.client = client
self.matches = []
def complete_request(self,text):
line = readline.get_line_buffer()
cursor_pos = readline.get_endidx()
# send completion request to kernel
# Give the kernel up to 0.5s to respond
msg_id = self.client.shell_channel.complete(text=text, line=line,
cursor_pos=cursor_pos)
msg = self.client.shell_channel.get_msg(timeout=self.timeout)
if msg['parent_header']['msg_id'] == msg_id:
return msg["content"]["matches"]
return []
def rlcomplete(self, text, state):
if state == 0:
try:
self.matches = self.complete_request(text)
except Empty:
#print('WARNING: Kernel timeout on tab completion.')
pass
try:
return self.matches[state]
except IndexError:
return None
def complete(self, text, line, cursor_pos=None):
return self.rlcomplete(text, 0)