gregsexton / ob-ipython

org-babel integration with Jupyter for evaluation of (Python by default) code blocks
737 stars 111 forks source link

"setDaemon() is deprecated, set the daemon attribute instead" error in client.py #221

Closed dinojr closed 1 year ago

dinojr commented 1 year ago

A recent upgrade of python broke ob-ipython for me. It turns out that the syntax of the call to threading.Thread in the definition of create_client has changed. One has to change:

def create_client(name):
    if name.endswith('.json'):
        cf = find_connection_file(name)
    else:
        cf = find_connection_file('emacs-' + name)
    c = client.BlockingKernelClient(connection_file=cf)
    c.load_connection_file()
    c.start_channels()
    io, shell = c.get_iopub_msg, c.get_shell_msg
    t = threading.Thread(target=msg_router, args=(io, shell))
    t.setDaemon(True)
    t.start()
    return c

to

def create_client(name):
    if name.endswith('.json'):
        cf = find_connection_file(name)
    else:
        cf = find_connection_file('emacs-' + name)
    c = client.BlockingKernelClient(connection_file=cf)
    c.load_connection_file()
    c.start_channels()
    io, shell = c.get_iopub_msg, c.get_shell_msg
    t = threading.Thread(target=msg_router, args=(io, shell),daemon=True)
    t.start()
    return c

While investigating this error I noticed that jupyter-console fails at startup. Changing

main_task = asyncio.wait(tasks, loop=loop,return_when=asyncio.FIRST_COMPLETED)

to

main_task = asyncio.wait(tasks,return_when=asyncio.FIRST_COMPLETED)

allows jupyter-console to run. I'm not sure the two problems are related, though.

See PR #222