blockingkernelmanager.py
53 lines
| 2.0 KiB
| text/x-python
|
PythonLexer
|
r8408 | """ Implements a fully blocking kernel manager. | ||
|
r2926 | |||
Useful for test suites and blocking terminal interfaces. | ||||
""" | ||||
#----------------------------------------------------------------------------- | ||||
|
r8408 | # Copyright (C) 2010-2012 The IPython Development Team | ||
|
r2926 | # | ||
# Distributed under the terms of the BSD License. The full license is in | ||||
# the file COPYING.txt, distributed as part of this software. | ||||
#----------------------------------------------------------------------------- | ||||
#----------------------------------------------------------------------------- | ||||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
|
r8408 | # Local imports. | ||
|
r8471 | from IPython.inprocess.blockingkernelmanager import BlockingChannelMixin | ||
|
r2926 | from IPython.utils.traitlets import Type | ||
|
r8408 | from kernelmanager import KernelManager, SubSocketChannel, HBSocketChannel, \ | ||
ShellSocketChannel, StdInSocketChannel | ||||
|
r2693 | |||
|
r2926 | #----------------------------------------------------------------------------- | ||
|
r8408 | # Blocking kernel manager | ||
|
r2926 | #----------------------------------------------------------------------------- | ||
|
r2693 | |||
|
r8408 | class BlockingSubSocketChannel(BlockingChannelMixin, SubSocketChannel): | ||
pass | ||||
|
r2926 | |||
|
r8408 | class BlockingShellSocketChannel(BlockingChannelMixin, ShellSocketChannel): | ||
pass | ||||
|
r2926 | |||
|
r8408 | class BlockingStdInSocketChannel(BlockingChannelMixin, StdInSocketChannel): | ||
pass | ||||
|
r2926 | |||
class BlockingHBSocketChannel(HBSocketChannel): | ||||
|
r3825 | |||
|
r5614 | # This kernel needs quicker monitoring, shorten to 1 sec. | ||
# less than 0.5s is unreliable, and will get occasional | ||||
# false reports of missed beats. | ||||
time_to_dead = 1. | ||||
|
r2926 | |||
def call_handlers(self, since_last_heartbeat): | ||||
|
r8408 | """ Pause beating on missed heartbeat. """ | ||
|
r3825 | pass | ||
|
r2926 | class BlockingKernelManager(KernelManager): | ||
# The classes to use for the various channels. | ||||
|
r3974 | shell_channel_class = Type(BlockingShellSocketChannel) | ||
|
r2926 | sub_channel_class = Type(BlockingSubSocketChannel) | ||
|
r3974 | stdin_channel_class = Type(BlockingStdInSocketChannel) | ||
|
r2926 | hb_channel_class = Type(BlockingHBSocketChannel) | ||