def preprocess(self, nb, resources):
    path = resources.get('metadata', {}).get('path', '')
    if (path == ''):
        path = None
    from jupyter_client.manager import start_new_kernel
    kernel_name = nb.metadata.get('kernelspec', {}).get('name', 'python')
    self.log.info(('Executing notebook with kernel: %s' % kernel_name))
    (self.km, self.kc) = start_new_kernel(kernel_name=kernel_name, extra_arguments=self.extra_arguments, stderr=open(os.devnull, 'w'), cwd=path)
    self.kc.allow_stdin = False
    try:
        (nb, resources) = super(ExecutePreprocessor, self).preprocess(nb, resources)
    finally:
        self.kc.stop_channels()
        self.km.shutdown_kernel(now=True)
    return (nb, resources)
def preprocess(self, nb, resources):
    path = resources.get('metadata', {}).get('path', )
    if (path == ):
        path = None
    from jupyter_client.manager import start_new_kernel
    kernel_name = nb.metadata.get('kernelspec', {}).get('name', 'python')
    self.log.info(('Executing notebook with kernel: %s' % kernel_name))
    (self.km, self.kc) = start_new_kernel(kernel_name=kernel_name, extra_arguments=self.extra_arguments, stderr=open(os.devnull, 'w'), cwd=path)
    self.kc.allow_stdin = False
    try:
        (nb, resources) = super(ExecutePreprocessor, self).preprocess(nb, resources)
    finally:
        self.kc.stop_channels()
        self.km.shutdown_kernel(now=True)
    return (nb, resources)