{"id":45766363,"url":"https://github.com/answerdotai/conkernelclient","last_synced_at":"2026-04-15T05:00:36.447Z","repository":{"id":340671954,"uuid":"1167075341","full_name":"AnswerDotAI/conkernelclient","owner":"AnswerDotAI","description":"Concurrent-safe Jupyter KernelClient","archived":false,"fork":false,"pushed_at":"2026-04-06T03:30:10.000Z","size":413,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-11T10:01:18.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://AnswerDotAI.github.io/conkernelclient","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnswerDotAI.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-25T23:12:35.000Z","updated_at":"2026-04-06T03:29:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"d46a4c52-6a5b-4f8f-b62b-b83b30b2117a","html_url":"https://github.com/AnswerDotAI/conkernelclient","commit_stats":null,"previous_names":["answerdotai/conkernelclient"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/AnswerDotAI/conkernelclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fconkernelclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fconkernelclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fconkernelclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fconkernelclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnswerDotAI","download_url":"https://codeload.github.com/AnswerDotAI/conkernelclient/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fconkernelclient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31826902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-02-26T01:58:13.316Z","updated_at":"2026-04-15T05:00:36.441Z","avatar_url":"https://github.com/AnswerDotAI.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# conkernelclient\n\n\n\u003c!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --\u003e\n\n## Background\n\nJupyter’s `KernelClient` is designed around a simple request-reply\npattern: you send one message on the shell channel, wait for its reply,\nthen send the next. This works fine for a single-threaded notebook, but\nfalls apart when you need concurrent execution. For instance, running\nmultiple cells in parallel, or letting an LLM tool loop fire off code\nwhile a long-running computation is still in flight. The underlying ZMQ\nsocket isn’t safe to share across tasks, and there’s no built-in\nmechanism to route replies back to the correct caller when multiple\nrequests are outstanding.\n\n*conkernelclient* solves this with\n[`ConKernelClient`](https://AnswerDotAI.github.io/conkernelclient/core.html#conkernelclient),\na drop-in replacement for `AsyncKernelClient` that makes concurrent\n`execute()` calls safe. It patches `Session.send` to synchronise with\nthe ZMQ I/O thread (preventing a race where two sends interleave), and\nspins up a dedicated reader task on the shell channel that demultiplexes\nincoming replies by message ID. Each `execute(..., reply=True)` call\ngets its own\n[`asyncio.Queue`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue),\nso multiple coroutines can `await` their replies independently without\ninterfering with each other.\n\n## Installation\n\nInstall from [pypi](https://pypi.org/project/conkernelclient/)\n\n``` sh\n$ pip install conkernelclient\n```\n\n## How to use\n\n``` python\nfrom conkernelclient import *\n```\n\nThe main entry point is\n[`ConKernelManager`](https://AnswerDotAI.github.io/conkernelclient/core.html#conkernelmanager),\na drop-in replacement for `AsyncKernelManager` that creates\n[`ConKernelClient`](https://AnswerDotAI.github.io/conkernelclient/core.html#conkernelclient)\ninstances. Start a kernel and connect a client in the usual way:\n\n``` python\nimport asyncio\nfrom jupyter_client.session import Session\n```\n\n``` python\nkm = ConKernelManager(session=Session(key=b'x'))\nawait km.start_kernel()\nkc = await km.client().start_channels()\nawait kc.is_alive()\n```\n\n    True\n\nOnce connected, `execute()` works like the standard client. Pass\n`reply=True` to await the shell reply, or `reply=False` (the default) to\nfire-and-forget and collect results later via `get_pubs`:\n\n``` python\nr = await kc.execute('2+1', timeout=1, reply=True)\nr['content']['status']\n```\n\n    'ok'\n\nThe key feature is safe concurrent execution. Multiple\n`execute(..., reply=True)` calls can be outstanding simultaneously —\neach gets its own\n[`asyncio.Queue`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue),\nand a background reader task routes replies by message ID:\n\n``` python\nfrom fastcore.test import test_eq\n```\n\n``` python\na = kc.execute('x=2', reply=True)\nb = kc.execute('y=3', reply=True)\nr = await asyncio.wait_for(asyncio.gather(a, b), timeout=2)\ntest_eq(len(r), 2)\nr[0]['parent_header']['msg_id']\n```\n\n    'dab23f68-96c28dd9c776844176afdff1_66028_2'\n\nBoth replies arrive independently, each routed to the correct caller.\nWithout\n[`ConKernelClient`](https://AnswerDotAI.github.io/conkernelclient/core.html#conkernelclient),\nthe second `execute` would either block waiting for the first to finish,\nor the replies would get crossed.\n\nAs usual, we clean up when we’re done:\n\n``` python\nif await km.is_alive():\n    kc.stop_channels()\n    await km.shutdown_kernel()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanswerdotai%2Fconkernelclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanswerdotai%2Fconkernelclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanswerdotai%2Fconkernelclient/lists"}