0

When running code in a Jupyter kernel it is possible to get the iopub or the shell messages from the respective channels. Is is possible to extract the raw python objects from the kernel as well?

Say for the below code

code = """a = {'a': 1}
b = {'b': 2}
"""


class Shell:
    def __init__(self):
        km = KernelManager()
        km.start_kernel()

        client = km.client()
        client.start_channels()

        client.execute(code)

        print(client.get_iopub_msg())
        print(client.get_shell_msg())

I want to retrieve the actual objects a and b so that they can be used in the current python application. Is that possible?

1 Answer 1

0

I found a workaround for it by using dill to dump the entire session inside the kernel

dill.dump_session()

And then load it in the main application

dill.load_session()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.