guysv / ilua

Portable Lua kernel for Jupyter
GNU General Public License v2.0
119 stars 12 forks source link

Exception 'coroutine' object is not subscriptable on typing anything #20

Closed averms closed 1 year ago

averms commented 2 years ago

I tried installing with pip into a clean virtual environment did the following:

$ ilua -i lua5.2
Jupyter console 6.4.0

ILua 0.2.1
In [1]: print'hi'

But I got a pretty long traceback:

jupyter_console/ptshell.py:852: RuntimeWarning: coroutine 'ZMQSocketChannel.msg_ready' was never awaited
  while self.client.iopub_channel.msg_ready():
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Unhandled exception in event loop:
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/input/vt100.py", line 168, in callback_wrapper
    callback()
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 691, in read_from_input
    self.key_processor.process_keys()
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 274, in process_keys
    self._process_coroutine.send(key_press)
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 186, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 329, in _call_handler
    handler.call(event)
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 102, in call
    result = self.handler(event)
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/jupyter_console/ptshell.py", line 475, in _
    self.handle_iopub()
  File "/home/aman/.local/python_venv/_ilua/lib/python3.9/site-packages/jupyter_console/ptshell.py", line 854, in handle_iopub
    msg_type = sub_msg['header']['msg_type']

Exception 'coroutine' object is not subscriptable

This seems to happen no matter what I type into the console.

guysv commented 2 years ago

Thanks for the report, will look into it today hopefully 🙏 .

It appears from a glance that some dependency was not pinned correctly. May you provide me with you operating system version?

guysv commented 2 years ago

I managed to reproduce the bug on a debian:bookworm container, will investigate!

raph-amiard commented 2 years ago

Hi here

FWIW, I reproduce on my debian install

averms commented 2 years ago

It appears from a glance that some dependency was not pinned correctly. May you provide me with you operating system version?

Sorry, I missed this. I'm using Arch Linux.

averms commented 2 years ago

Might be related to jupyter/jupyter_console#241

EDIT: Problem goes away if you downgrade jupyter-client to 6.1.12. The exact set of steps:

  1. virtualenv venv && . venv/bin/activate
  2. pip install jupyter_client=='6.*'
  3. pip install git+https://github.com/guysv/ilua.git@master
  4. ilua -i lua5.2 and everything works.
hroncok commented 2 years ago

I've got this immediatelly:

ILua 0.2.1Traceback (most recent call last):
  File "/builddir/__venv__/bin/ilua", line 8, in <module>
    sys.exit(main())
  File "/builddir/__venv__/lib64/python3.10/site-packages/ilua/consoleapp.py", line 37, in main
    ILuaConsoleApp().run()
  File "/builddir/__venv__/lib64/python3.10/site-packages/ilua/consoleapp.py", line 34, in run
    ZMQTerminalIPythonApp.launch_instance(argv=['--kernel', 'lua'])
  File "/builddir/__venv__/lib64/python3.10/site-packages/jupyter_core/application.py", line 264, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/builddir/__venv__/lib64/python3.10/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/builddir/__venv__/lib64/python3.10/site-packages/jupyter_console/app.py", line 148, in start
    self.shell.mainloop()
  File "/builddir/__venv__/lib64/python3.10/site-packages/jupyter_console/ptshell.py", line 664, in mainloop
    main_task = asyncio.wait(tasks, loop=loop, return_when=asyncio.FIRST_COMPLETED)
TypeError: wait() got an unexpected keyword argument 'loop'
sys:1: RuntimeWarning: coroutine 'ZMQTerminalInteractiveShell.interact' was never awaited

With fresh venv install of ilua from pypi on Python 3.10:

Package           Version
----------------- -------
attrs             21.4.0
Automat           20.2.0
backcall          0.2.0
constantly        15.1.0
debugpy           1.5.1
decorator         5.1.0
entrypoints       0.3
hyperlink         21.0.0
idna              3.3
ilua              0.2.1
incremental       21.3.0
ipykernel         6.6.0
ipython           7.30.1
jedi              0.18.1
jupyter-client    7.1.0
jupyter-console   6.4.0
jupyter-core      4.9.1
matplotlib-inline 0.1.3
nest-asyncio      1.5.4
parso             0.8.3
pexpect           4.8.0
pickleshare       0.7.5
pip               21.3.1
prompt-toolkit    3.0.24
ptyprocess        0.7.0
Pygments          2.11.1
python-dateutil   2.8.2
pyzmq             22.3.0
setuptools        59.6.0
six               1.16.0
termcolor         1.1.0
tornado           6.1
traitlets         5.1.1
Twisted           21.7.0
txZMQ             1.0.0
typing_extensions 4.0.1
wcwidth           0.2.5
zope.interface    5.4.0

And I also get this after hitting enter when selecting something from the autocomplete option list:

ILua 0.2.1

Unhandled exception in event loop:
  File "/usr/lib64/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/input/vt100.py", line 170, in callback_wrapper
    callback()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 690, in read_from_input
    self.key_processor.process_keys()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 271, in process_keys
    self._process_coroutine.send(key_press)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 186, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 321, in _call_handler
    handler.call(event)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 124, in call
    result = self.handler(event)
  File "/usr/lib/python3.10/site-packages/jupyter_console/ptshell.py", line 486, in _
    more, indent = self.check_complete(d.text)
  File "/usr/lib/python3.10/site-packages/jupyter_console/ptshell.py", line 609, in check_complete
    return self.handle_is_complete_reply(msg_id,
  File "/usr/lib/python3.10/site-packages/jupyter_console/ptshell.py", line 790, in handle_is_complete_reply
    msg = run_sync(self.client.shell_channel.get_msg)(block=True, timeout=timeout)
  File "/usr/lib/python3.10/site-packages/jupyter_client/utils.py", line 21, in wrapped
    future = asyncio.ensure_future(coro(*args, **kwargs))

Exception ZMQSocketChannel.get_msg() got an unexpected keyword argument 'block'

On Fedora 36 with system packages:

Package           Version
----------------- --------
attrs             21.2.0
Automat           20.2.0
backcall          0.1.0
constantly        15.1.0
decorator         5.1.0
entrypoints       0.3
hyperlink         21.0.0
idna              3.3
ilua              0.2.1
incremental       21.3.0
ipykernel         6.4.1
ipython           7.29.0
ipython_genutils  0.2.0
jedi              0.18.1
jupyter-client    7.1.0
jupyter-console   6.4.0
jupyter-core      4.9.1
matplotlib-inline 0.1.2
nest-asyncio      1.5.4
parso             0.8.2
pexpect           4.8.0
pickleshare       0.7.5
pip               21.3.1
prompt-toolkit    3.0.24
ptyprocess        0.6.0
pycurl            7.44.1
Pygments          2.10.0
python-dateutil   2.8.1
pyzmq             22.2.1
setuptools        59.6.0
six               1.16.0
termcolor         1.1.0
tornado           6.1
traitlets         5.1.1
Twisted           21.7.0
txZMQ             1.0.0
typing-extensions 3.10.0.2
wcwidth           0.2.5
zope.interface    5.4.0

I comment here instead of opening another issue because I believe this is all related to some updated depndency.

hroncok commented 2 years ago

So https://github.com/jupyter/jupyter_console/pull/244 appears to fix this.

WolfangAukang commented 2 years ago

FYI, I was able to reproduce this on NixOS. Using Jupyter console 6.4.0 and ILua 0.2.1.

ahillio commented 2 years ago

This looks like a problem with jupyter_console itself. I get this same traceback (everytime, just as in ilua) when I run jupyter_console itself from my terminal.

In [1]: exit/home/me/.local/lib/python3.8/site-packages/jupyter_console/ptshell.py:852: RuntimeWarning: coroutine 'ZMQSocketChannel.msg_ready' was never awaited
  while self.client.iopub_channel.msg_ready():
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Unhandled exception in event loop:
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/input/vt100.py", line 168, in callback_wrapper
    callback()
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 691, in read_from_input
    self.key_processor.process_keys()
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/key_binding/key_processor.py", line 274, in process_keys
    self._process_coroutine.send(key_press)
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/key_binding/key_processor.py", line 186, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/key_binding/key_processor.py", line 329, in _call_handler
    handler.call(event)
  File "/home/me/.local/lib/python3.8/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 102, in call
    result = self.handler(event)
  File "/home/me/.local/lib/python3.8/site-packages/jupyter_console/ptshell.py", line 475, in _
    self.handle_iopub()
  File "/home/me/.local/lib/python3.8/site-packages/jupyter_console/ptshell.py", line 854, in handle_iopub
    msg_type = sub_msg['header']['msg_type']

Exception 'coroutine' object is not subscriptable

I'm investing the solution @hroncok apparently found...

ahillio commented 2 years ago

Indeed. Solved with pip3 install --upgrade jupyter_console, updating that (I think these are the versions) from 6.4.0 to 6.4.3.

averms commented 1 year ago

Closing since it seems to be fixed now.