##// END OF EJS Templates
relocate redundantly-named kernel files...
MinRK -
Show More
1 NO CONTENT: new file 100644
1 NO CONTENT: new file 100644
@@ -25,14 +25,14 b' from .kernelmanager import KernelManager, IOPubChannel, HBChannel, \\'
25 25
26 26
27 27 class BlockingChannelMixin(object):
28
28
29 29 def __init__(self, *args, **kwds):
30 30 super(BlockingChannelMixin, self).__init__(*args, **kwds)
31 31 self._in_queue = Queue.Queue()
32
32
33 33 def call_handlers(self, msg):
34 34 self._in_queue.put(msg)
35
35
36 36 def get_msg(self, block=True, timeout=None):
37 37 """ Gets a message if there is one that is ready. """
38 38 if timeout is None:
@@ -40,7 +40,7 b' class BlockingChannelMixin(object):'
40 40 # behavior, so wait for a week instead
41 41 timeout = 604800
42 42 return self._in_queue.get(block, timeout)
43
43
44 44 def get_msgs(self):
45 45 """ Get all messages that are currently ready. """
46 46 msgs = []
@@ -50,7 +50,7 b' class BlockingChannelMixin(object):'
50 50 except Queue.Empty:
51 51 break
52 52 return msgs
53
53
54 54 def msg_ready(self):
55 55 """ Is there a message that has been received? """
56 56 return not self._in_queue.empty()
@@ -69,7 +69,7 b' class BlockingStdInChannel(BlockingChannelMixin, StdInChannel):'
69 69
70 70
71 71 class BlockingHBChannel(HBChannel):
72
72
73 73 # This kernel needs quicker monitoring, shorten to 1 sec.
74 74 # less than 0.5s is unreliable, and will get occasional
75 75 # false reports of missed beats.
@@ -87,4 +87,3 b' class BlockingKernelManager(KernelManager):'
87 87 iopub_channel_class = Type(BlockingIOPubChannel)
88 88 stdin_channel_class = Type(BlockingStdInChannel)
89 89 hb_channel_class = Type(BlockingHBChannel)
90
1 NO CONTENT: file renamed from IPython/kernel/ioloopkernelmanager.py to IPython/kernel/ioloop/manager.py
1 NO CONTENT: file renamed from IPython/kernel/ioloopkernelrestarter.py to IPython/kernel/ioloop/restarter.py
@@ -128,7 +128,7 b' class ZMQSocketChannel(Thread):'
128 128 address = "tcp://%s:%i" % address
129 129 self._address = address
130 130 atexit.register(self._notice_exit)
131
131
132 132 def _notice_exit(self):
133 133 self._exiting = True
134 134
@@ -169,11 +169,11 b' class ZMQSocketChannel(Thread):'
169 169
170 170 def _queue_send(self, msg):
171 171 """Queue a message to be sent from the IOLoop's thread.
172
172
173 173 Parameters
174 174 ----------
175 175 msg : message to send
176
176
177 177 This is threadsafe, as it uses IOLoop.add_callback to give the loop's
178 178 thread control of the action.
179 179 """
@@ -188,7 +188,7 b' class ZMQSocketChannel(Thread):'
188 188 """
189 189 ident,smsg = self.session.feed_identities(msg)
190 190 self.call_handlers(self.session.unserialize(smsg))
191
191
192 192
193 193
194 194 class ShellChannel(ZMQSocketChannel):
@@ -260,7 +260,7 b' class ShellChannel(ZMQSocketChannel):'
260 260 allow_stdin : bool, optional (default self.allow_stdin)
261 261 Flag for whether the kernel can send stdin requests to frontends.
262 262
263 Some frontends (e.g. the Notebook) do not support stdin requests.
263 Some frontends (e.g. the Notebook) do not support stdin requests.
264 264 If raw_input is called from code executed from such a frontend, a
265 265 StdinNotImplementedError will be raised.
266 266
@@ -274,8 +274,8 b' class ShellChannel(ZMQSocketChannel):'
274 274 user_expressions = {}
275 275 if allow_stdin is None:
276 276 allow_stdin = self.allow_stdin
277
278
277
278
279 279 # Don't waste network traffic if inputs are invalid
280 280 if not isinstance(code, basestring):
281 281 raise ValueError('code %r must be a string' % code)
@@ -542,17 +542,17 b' class HBChannel(ZMQSocketChannel):'
542 542 self.socket = self.context.socket(zmq.REQ)
543 543 self.socket.setsockopt(zmq.LINGER, 0)
544 544 self.socket.connect(self.address)
545
545
546 546 self.poller.register(self.socket, zmq.POLLIN)
547
547
548 548 def _poll(self, start_time):
549 549 """poll for heartbeat replies until we reach self.time_to_dead.
550
550
551 551 Ignores interrupts, and returns the result of poll(), which
552 552 will be an empty list if no messages arrived before the timeout,
553 553 or the event tuple if there is a message to receive.
554 554 """
555
555
556 556 until_dead = self.time_to_dead - (time.time() - start_time)
557 557 # ensure poll at least once
558 558 until_dead = max(until_dead, 1e-3)
@@ -583,13 +583,13 b' class HBChannel(ZMQSocketChannel):'
583 583 self._create_socket()
584 584 self._running = True
585 585 self._beating = True
586
586
587 587 while self._running:
588 588 if self._pause:
589 589 # just sleep, and skip the rest of the loop
590 590 time.sleep(self.time_to_dead)
591 591 continue
592
592
593 593 since_last_heartbeat = 0.0
594 594 # io.rprint('Ping from HB channel') # dbg
595 595 # no need to catch EFSM here, because the previous event was
@@ -683,11 +683,11 b' class KernelManager(Configurable):'
683 683
684 684 # The kernel process with which the KernelManager is communicating.
685 685 # generally a Popen instance
686 kernel = Any()
687
686 kernel = Any()
687
688 688 kernel_cmd = List(Unicode, config=True,
689 689 help="""The Popen Command to launch the kernel.
690 Override this if you have a custom
690 Override this if you have a custom
691 691 """
692 692 )
693 693
@@ -698,7 +698,7 b' class KernelManager(Configurable):'
698 698
699 699 # The addresses for the communication channels.
700 700 connection_file = Unicode('')
701
701
702 702 transport = CaselessStrEnum(['tcp', 'ipc'], default_value='tcp', config=True)
703 703
704 704 ip = Unicode(LOCALHOST, config=True,
@@ -756,7 +756,7 b' class KernelManager(Configurable):'
756 756
757 757 This will create the channels if they do not exist and then start
758 758 them (their activity runs in a thread). If port numbers of 0 are
759 being used (random ports) then you must first call
759 being used (random ports) then you must first call
760 760 :method:`start_kernel`. If the channels have been stopped and you
761 761 call this, :class:`RuntimeError` will be raised.
762 762 """
@@ -844,10 +844,10 b' class KernelManager(Configurable):'
844 844 #--------------------------------------------------------------------------
845 845 # Connection and ipc file management
846 846 #--------------------------------------------------------------------------
847
847
848 848 def cleanup_connection_file(self):
849 849 """Cleanup connection file *if we wrote it*
850
850
851 851 Will not raise if the connection file was already removed somehow.
852 852 """
853 853 if self._connection_file_written:
@@ -857,7 +857,7 b' class KernelManager(Configurable):'
857 857 os.remove(self.connection_file)
858 858 except (IOError, OSError, AttributeError):
859 859 pass
860
860
861 861 def cleanup_ipc_files(self):
862 862 """Cleanup ipc files if we wrote them."""
863 863 if self.transport != 'ipc':
@@ -883,7 +883,7 b' class KernelManager(Configurable):'
883 883 self.iopub_port = cfg['iopub_port']
884 884 self.hb_port = cfg['hb_port']
885 885 self.session.key = str_to_bytes(cfg['key'])
886
886
887 887 def write_connection_file(self):
888 888 """Write connection info to JSON dict in self.connection_file."""
889 889 if self._connection_file_written:
@@ -897,7 +897,7 b' class KernelManager(Configurable):'
897 897 self.stdin_port = cfg['stdin_port']
898 898 self.iopub_port = cfg['iopub_port']
899 899 self.hb_port = cfg['hb_port']
900
900
901 901 self._connection_file_written = True
902 902
903 903 #--------------------------------------------------------------------------
@@ -926,14 +926,14 b' class KernelManager(Configurable):'
926 926 ns = dict(connection_file=self.connection_file)
927 927 ns.update(self._launch_args)
928 928 return [ c.format(**ns) for c in cmd ]
929
929
930 930 def _launch_kernel(self, kernel_cmd, **kw):
931 931 """actually launch the kernel
932
932
933 933 override in a subclass to launch kernel subprocesses differently
934 934 """
935 935 return launch_kernel(kernel_cmd, **kw)
936
936
937 937 def start_kernel(self, **kw):
938 938 """Starts a kernel on this host in a separate process.
939 939
@@ -952,7 +952,7 b' class KernelManager(Configurable):'
952 952 "configured properly. "
953 953 "Currently valid addresses are: %s"%LOCAL_IPS
954 954 )
955
955
956 956 # write connection file / get default ports
957 957 self.write_connection_file()
958 958
@@ -967,7 +967,7 b' class KernelManager(Configurable):'
967 967 self.start_restarter()
968 968
969 969 def shutdown_kernel(self, now=False, restart=False):
970 """Attempts to the stop the kernel process cleanly.
970 """Attempts to the stop the kernel process cleanly.
971 971
972 972 This attempts to shutdown the kernels cleanly by:
973 973
@@ -1144,4 +1144,3 b' IOPubChannelABC.register(IOPubChannel)'
1144 1144 HBChannelABC.register(HBChannel)
1145 1145 StdInChannelABC.register(StdInChannel)
1146 1146 KernelManagerABC.register(KernelManager)
1147
@@ -223,4 +223,3 b' class KernelManagerABC(object):'
223 223 @abc.abstractmethod
224 224 def is_alive(self):
225 225 pass
226
General Comments 0
You need to be logged in to leave comments. Login now