##// END OF EJS Templates
Move kernel starting / stopping into preprocess()
Julia Evans -
Show More
@@ -24,15 +24,16 b' class ExecutePreprocessor(Preprocessor):'
24 24 """
25 25 Executes all the cells in a notebook
26 26 """
27 def __init__(self, *args, **kwargs):
27 def __init__(self, extra_arguments=[], **kwargs):
28 28 """
29 29 Start an kernel to run the Python code
30 30 """
31 super(ExecutePreprocessor, self).__init__(*args, **kwargs)
31 super(ExecutePreprocessor, self).__init__(**kwargs)
32 self.extra_arguments = []
33
34 def preprocess(self, nb, resources):
32 35 self.km = KernelManager()
33 # run %pylab inline, because some notebooks assume this
34 # even though they shouldn't
35 self.km.start_kernel(extra_arguments=['--pylab=inline'], stderr=open(os.devnull, 'w'))
36 self.km.start_kernel(extra_arguments=self.extra_arguments, stderr=open(os.devnull, 'w'))
36 37 self.kc = self.km.client()
37 38 self.kc.start_channels()
38 39 self.iopub = self.kc.iopub_channel
@@ -41,6 +42,12 b' class ExecutePreprocessor(Preprocessor):'
41 42 self.shell.execute("pass")
42 43 self.shell.get_msg()
43 44
45
46 create_client()
47 nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
48 shutdown_client()
49 return nb, resources
50
44 51 def preprocess_cell(self, cell, resources, cell_index):
45 52 """
46 53 Apply a transformation on each code cell. See base.py for details.
General Comments 0
You need to be logged in to leave comments. Login now