Skip to main content

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:

Metadata

Release files for background-zmq-ipython 1.20220901.135250

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for background-zmq-ipython 1.20220901.135250
File Size Uploaded
background_zmq_ipython-1.20220901.135250.tar.gz 8.6 kB Details

Release files / background_zmq_ipython-1.20220901.135250.tar.gz

Download URL background_zmq_ipython-1.20220901.135250.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
01dc3423b81714f493f572599507df9c15137edcbd379fa6df9e089db37ad987
BLAKE2b-256 checksum
How to use checksums
74b458c53c3f15583cf4ee351c781bf8df1ed0e3aafb9937d1e54352585b053f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page