From the web server (Python/tornado) I would like to execute some python code on the kernel.
Is that possible? So far, I can see which kernel ID are running but not sure how to issue some Python code and get some results from that kernel.
Basically I would like to do something like
PY_EXEC = """
try:
import json
from trame.app import AVAILABLE_SERVERS
reply(json.dumps(list(AVAILABLE_SERVERS.keys())))
except:
reply("[]")
"""
class RouteHandler(APIHandler):
@tornado.web.authenticated
def get(self):
config = {}
km = self.kernel_manager
for k_id in km.list_kernel_ids():
response = exec_in_kernel(k_id, PY_EXEC)
config[k_id] = json.load(response)
self.finish(json.dumps(config))
Any pointer would be great!
Thanks,
Seb