Git Product home page Git Product logo

Comments (10)

gforsyth avatar gforsyth commented on May 27, 2024 2

Thanks @anki-code -- merged and released 0.15.0. Going to leave this issue open until we sort out the upstream issue or figure out what part of xonsh is tripping up prompt toolkit

from xonsh.

anki-code avatar anki-code commented on May 27, 2024 1

I can reproduce this on Mac in case of alias with group of commands:

pip install 'xonsh[full]'
xonsh --no-rc
aliases['ttt'] = 'echo 1 && echo 2'
ttt
# 1
# 2
# <Press enter>
# <Press enter>
# Exception:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 73, in close
    loop.run_until_complete(loop.shutdown_default_executor())
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
    self.run_forever()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
    self._run_once()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1884, in _run_once
    event_list = self._selector.select(timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/selectors.py", line 566, in select
    kev_list = self._selector.control(None, max_ev, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/main.py", line 469, in main
    sys.exit(main_xonsh(args))
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/main.py", line 513, in main_xonsh
    shell.shell.cmdloop()
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/ptk_shell/shell.py", line 405, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/ptk_shell/shell.py", line 373, in singleline
    line = self.prompter.prompt(**prompt_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1026, in prompt
    return self.app.run(
           ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 1002, in run
    return asyncio.run(coro)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 189, in run
    with Runner(debug=debug) as runner:
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 63, in __exit__
    self.close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 77, in close
    loop.close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/unix_events.py", line 68, in close
    super().close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 91, in close
    self._close_self_pipe()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 99, in _close_self_pipe
    self._ssock.close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 503, in close
    self._real_close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 497, in _real_close
    _ss.close(self)
OSError: [Errno 9] Bad file descriptor
Xonsh encountered an issue during launch
Failback to /bin/zsh

from xonsh.

anki-code avatar anki-code commented on May 27, 2024

Just to add link to #4224

from xonsh.

anki-code avatar anki-code commented on May 27, 2024

I found that issue appeared starting from prompt-toolkit 3.0.41 where asyncio was introduced (prompt-toolkit/python-prompt-toolkit@8c60193).

To fix this just downgrade the prompt-toolkit version:

xpip uninstall -y prompt-toolkit
xpip install prompt-toolkit==3.0.40

The issue was reported to upstream - prompt-toolkit/python-prompt-toolkit#1853

from xonsh.

anki-code avatar anki-code commented on May 27, 2024

@gforsyth hey! Please see my comment above. It looks like this issue is pretty critical because creates unstable behavior e.g. I see this report in news.ycombinator.com. May be we need to pin prompt-toolkit to <=3.0.40 until the issue with asyncio will be fixed. What do you think?

from xonsh.

doronz88 avatar doronz88 commented on May 27, 2024

I believe this is the only way for now, though popular packages such as IPython do require newer prompt-toolkit. I guess the better choice is to add this requirement for the meantime and encourage people to install xonsh with pipx.

from xonsh.

gforsyth avatar gforsyth commented on May 27, 2024

I'll be at a computer later and can take a look. In the mean time, if someone can PR the upper pin and add a note to the docs that'll make it faster to release.

from xonsh.

anki-code avatar anki-code commented on May 27, 2024

@gforsyth here it is - #5288

from xonsh.

doronz88 avatar doronz88 commented on May 27, 2024

@gforsyth @anki-code this bug persists even after this fix - but much less
now usually the "Bad File Descriptor" exception doesn't mess with the whole shell

from xonsh.

anki-code avatar anki-code commented on May 27, 2024

I confirm this. The simple cases like alias for echo 1 && echo 2 are working on downgraded ptk but the error appears sometimes but without crashing the entire shell.

I'm also facing with this during typing the command:

 File "/opt/homebrew/lib/python3.11/site-packages/xonsh/main.py", line 470, in main
    sys.exit(main_xonsh(args))
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/main.py", line 514, in main_xonsh
    shell.shell.cmdloop()
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/ptk_shell/shell.py", line 406, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/xonsh/ptk_shell/shell.py", line 374, in singleline
    line = self.prompter.prompt(**prompt_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1024, in prompt
    return self.app.run(
           ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 973, in run
    return loop.run_until_complete(coro)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
    self.run_forever()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
    self._run_once()
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1884, in _run_once
    event_list = self._selector.select(timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/selectors.py", line 566, in select
    kev_list = self._selector.control(None, max_ev, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor

from xonsh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.