guysv / ilua

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

Operation not permitted when piping in stdin #11

Closed hroncok closed 4 years ago

hroncok commented 4 years ago

I wanted to write a simple smoke test, but this is where I ended up:

$ ilua << EOF
print"test"
EOF
Warning: Input is not to a terminal (fd=0).
Jupyter console 6.1.0

ILua 0.2.1
Traceback (most recent call last):
  File "/usr/bin/ilua", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/ilua/consoleapp.py", line 37, in main
    ILuaConsoleApp().run()
  File "/usr/lib/python3.8/site-packages/ilua/consoleapp.py", line 34, in run
    ZMQTerminalIPythonApp.launch_instance(argv=['--kernel', 'lua'])
  File "/usr/lib/python3.8/site-packages/jupyter_core/application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/usr/lib/python3.8/site-packages/jupyter_console/app.py", line 156, in start
    self.shell.mainloop()
  File "/usr/lib/python3.8/site-packages/jupyter_console/ptshell.py", line 547, in mainloop
    self.interact()
  File "/usr/lib/python3.8/site-packages/jupyter_console/ptshell.py", line 531, in interact
    code = self.prompt_for_code()
  File "/usr/lib/python3.8/site-packages/jupyter_console/ptshell.py", line 474, in prompt_for_code
    text = self.pt_cli.prompt(
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 797, in prompt
    return run_sync()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 786, in run_sync
    return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 736, in run
    return run()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 710, in run
    return f.result()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/future.py", line 151, in result
    raise self._exception
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/coroutine.py", line 92, in step_next
    new_f = coroutine.throw(exc)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 685, in _run_async2
    result = yield f
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/coroutine.py", line 88, in step_next
    new_f = coroutine.send(None)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 625, in _run_async
    with self.input.attach(read_from_input):
  File "/usr/lib64/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/input/vt100.py", line 150, in _attached_input
    loop.add_reader(fd, callback)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/posix.py", line 273, in add_reader
    self.selector.register(fd)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/select.py", line 78, in register
    sel.register(fd)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/eventloop/select.py", line 133, in register
    self._sel.register(fd, selectors.EVENT_READ, None)
  File "/usr/lib64/python3.8/selectors.py", line 359, in register
    self._selector.register(key.fd, poller_events)
PermissionError: [Errno 1] Operation not permitted
guysv commented 4 years ago

I think that issue should be solved at jupyter frontend's scope. Other kernels could benefit from such feature too.

ilua is really just a thin wrapper around jupyter-console --kernel lua, so jupyter should handle the input redirection.

hroncok commented 4 years ago

https://github.com/jupyter/jupyter_console/issues/213