##// END OF EJS Templates
copy _execute_sleep trait from ipkernel to pykernel...
MinRK -
Show More
@@ -25,7 +25,7 b' import traceback'
25 import zmq
25 import zmq
26
26
27 # Local imports.
27 # Local imports.
28 from IPython.utils.traitlets import HasTraits, Instance
28 from IPython.utils.traitlets import HasTraits, Instance, Float
29 from completer import KernelCompleter
29 from completer import KernelCompleter
30 from entry_point import base_launch_kernel, make_default_main
30 from entry_point import base_launch_kernel, make_default_main
31 from session import Session, Message
31 from session import Session, Message
@@ -38,6 +38,15 b' class Kernel(HasTraits):'
38
38
39 # Private interface
39 # Private interface
40
40
41 # Time to sleep after flushing the stdout/err buffers in each execute
42 # cycle. While this introduces a hard limit on the minimal latency of the
43 # execute cycle, it helps prevent output synchronization problems for
44 # clients.
45 # Units are in seconds. The minimum zmq latency on local host is probably
46 # ~150 microseconds, set this to 500us for now. We may need to increase it
47 # a little if it's not enough after more interactive testing.
48 _execute_sleep = Float(0.0005, config=True)
49
41 # This is a dict of port number that the kernel is listening on. It is set
50 # This is a dict of port number that the kernel is listening on. It is set
42 # by record_ports and used by connect_request.
51 # by record_ports and used by connect_request.
43 _recorded_ports = None
52 _recorded_ports = None
@@ -137,6 +146,11 b' class Kernel(HasTraits):'
137 # Flush output before sending the reply.
146 # Flush output before sending the reply.
138 sys.stderr.flush()
147 sys.stderr.flush()
139 sys.stdout.flush()
148 sys.stdout.flush()
149 # FIXME: on rare occasions, the flush doesn't seem to make it to the
150 # clients... This seems to mitigate the problem, but we definitely need
151 # to better understand what's going on.
152 if self._execute_sleep:
153 time.sleep(self._execute_sleep)
140
154
141 # Send the reply.
155 # Send the reply.
142 reply_msg = self.session.send(self.reply_socket, u'execute_reply', reply_content, parent, ident=ident)
156 reply_msg = self.session.send(self.reply_socket, u'execute_reply', reply_content, parent, ident=ident)
General Comments 0
You need to be logged in to leave comments. Login now