{"id":14977389,"url":"https://github.com/albertz/background-zmq-ipython","last_synced_at":"2025-10-28T03:32:15.777Z","repository":{"id":45414145,"uuid":"168712122","full_name":"albertz/background-zmq-ipython","owner":"albertz","description":"Background ZMQ IPython/Jupyter kernel","archived":false,"fork":false,"pushed_at":"2023-07-17T09:48:29.000Z","size":37,"stargazers_count":17,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T11:24:17.013Z","etag":null,"topics":["ipython","jupyter","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/albertz.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-01T14:48:19.000Z","updated_at":"2024-03-31T22:02:07.000Z","dependencies_parsed_at":"2024-09-28T00:00:59.079Z","dependency_job_id":null,"html_url":"https://github.com/albertz/background-zmq-ipython","commit_stats":{"total_commits":51,"total_committers":6,"mean_commits":8.5,"dds":"0.43137254901960786","last_synced_commit":"71e23d8fa9e14982aeb2e2ff3e56bcdcbed4b7cf"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertz%2Fbackground-zmq-ipython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertz%2Fbackground-zmq-ipython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertz%2Fbackground-zmq-ipython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertz%2Fbackground-zmq-ipython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertz","download_url":"https://codeload.github.com/albertz/background-zmq-ipython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238590596,"owners_count":19497350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipython","jupyter","python"],"created_at":"2024-09-24T13:55:34.467Z","updated_at":"2025-10-28T03:32:10.513Z","avatar_url":"https://github.com/albertz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Run some IPython ZMQ kernel in the background, without an interactive shell.\nYou can connect to that kernel remotely via ZMQ.\n\nInstallation (`package is on PyPI \u003chttps://pypi.org/project/background_zmq_ipython/\u003e`_)::\n\n    pip install background_zmq_ipython\n\nUsage::\n\n    import background_zmq_ipython\n    background_zmq_ipython.init_ipython_kernel()\n\nThe kernel will then run in the background in its own thread.\nThe init will print some message similar to this on stdout::\n\n    To connect another client to this IPython kernel, use:\n    jupyter console --existing kernel-1111.json\n\nNow, after you connected, how to access globals from the main module? E.g. let's say there is a variable ``a``.\n\n* ``sys.modules[\"__main__\"].a`` should work.\n  Via ``sys.modules``, you can access all the imported modules. Or just do ``import mod`` again.\n* Get the stack of all/other frames via ``sys._current_frames()``,\n  and there you can access the globals from other threads as well.\n* You can provide ``user_ns`` to ``init_ipython_kernel``, e.g::\n\n    init_ipython_kernel(user_ns=globals())\n\n  or::\n  \n    init_ipython_kernel(user_ns={\"main_globals\": globals()})\n\n  or::\n  \n    init_ipython_kernel(user_ns={\"a\": a})\n\n\nAlternatives / related links:\n\n* `pydbattach \u003chttps://github.com/albertz/pydbattach\u003e`_\n* `Twisted SSH \u003chttps://crochet.readthedocs.io/en/stable/introduction.html#ssh-into-your-server\u003e`_\n  (`example code \u003chttps://github.com/msabramo/pyramid_ssh_crochet/blob/master/pyramid_ssh_crochet.py\u003e`__)\n* ``IPython.embed_kernel`` in a background thread\n  (`example code \u003chttps://github.com/msabramo/pyramid_ipython_kernel/blob/master/pyramid_ipython_kernel.py\u003e`__).\n  This has some issues\n  (e.g. `here \u003chttps://github.com/ipython/ipython/issues/4032\u003e`_;\n  messing around with ``sys.stdout`` etc).\n* This code was introduced in\n  `this StackOverflow question \u003chttps://stackoverflow.com/questions/29148319/provide-remote-shell-for-python-script\u003e`_,\n  and also discussed in this `IPython GitHub issue #8097 \u003chttps://github.com/ipython/ipython/issues/8097\u003e`_,\n  but it has become outdated, so this project provides a rewrite / updated code,\n  and the goal was also an easy to install pip package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertz%2Fbackground-zmq-ipython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertz%2Fbackground-zmq-ipython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertz%2Fbackground-zmq-ipython/lists"}