Skip to main content

Background ZMQ IPython/Jupyter kernel

Project description

Run some IPython ZMQ kernel in the background, without an interactive shell. You can connect to that kernel remotely via ZMQ.

Installation (package is on PyPI):

pip install background_zmq_ipython

Usage:

import background_zmq_ipython
background_zmq_ipython.init_ipython_kernel()

The kernel will then run in the background in its own thread. The init will print some message similar to this on stdout:

To connect another client to this IPython kernel, use:
jupyter console --existing kernel-1111.json

Now, after you connected, how to access globals from the main module? E.g. let’s say there is a variable a.

  • sys.modules["__main__"].a should work. Via sys.modules, you can access all the imported modules. Or just do import mod again.

  • Get the stack of all/other frames via sys._current_frames(), and there you can access the globals from other threads as well.

  • You can provide user_ns to init_ipython_kernel, e.g:

    init_ipython_kernel(user_ns=globals())

    or:

    init_ipython_kernel(user_ns={"main_globals": globals()})

    or:

    init_ipython_kernel(user_ns={"a": a})

Alternatives / related links:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

background_zmq_ipython-1.20200202.222340.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file background_zmq_ipython-1.20200202.222340.tar.gz.

File metadata

File hashes

Hashes for background_zmq_ipython-1.20200202.222340.tar.gz
Algorithm Hash digest
SHA256 26b335eb19dd8ba67850e192ec9a2083ed022dd8a29624a81281e9d030277ec7
MD5 f1d8a27b542d3417be39ae3a1c66c60d
BLAKE2b-256 3b7b62e25f57e91cd9fd7151092b8305081cdb4f0020c5a580eff1ed5514bf31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page