Comments (1)
After tracing this I understand the case. In the nutshell: if the last command in the pipe has no waiting for stdin (e.g. echo
, ls
, head -n0
, etc) the CommandPipeline will stop immediately and
-
If we have callable alias in pipe this leads to IO errors e.g.
callias | echo
will lead to descriptors error becausecallias
is working in thread and operating with std but std was closed by the main thread after finishing last process (echo
). -
If we have process in the pipe it will continue working in the background e.g.
sleep 999 | echo
will return prompt but hassleep
in the background without any notifications. If you repeat this in Bash it simply waits for the end of each process in the pipe.
We need to refactor core logic of CommandPipeline.iterraw(). I described the goal here.
Here is tracing two cases that are the result of the current logic.
Case 1: race condition in prompt
Steps:
-
Run
a | head -n0
. Here-n0
leads to stophead
immediately. This code will be executed:Lines 387 to 390 in 9e86938
- Here we create Tee - wrapper for std with memory buffer.
- And run the command with case of callable alias. It works in thread AND NOT blocking the execution.
-
While callable alias is working we achieve this line in the same code block:
Line 423 in 9e86938
- Here memory buffer will be closed BUT the callable alias still executing. We have something like race condition.
-
When callable alias tries to operate with memory buffer it already closed and we see
I/O operation on closed file
. When I'm saying "memory buffer" I mean this memory buffer that Tee manages and _TeeStd operates:Line 264 in 9e86938
Line 272 in 9e86938
Case 2: callable alias and loop
If we run:
for i in range(0,10):
a | head -n0
We will have multiple randomly spreaded "Bad file descriptor" errors. I tried to trace them but gave it up because it's obvious that the errors are from intersection of multiple threads that are working at once because of head -n0
stopped immediately.
from xonsh.
Related Issues (20)
- Process and subprocess
- Refactoring: parser
- Refactoring: operators
- Refactoring: aliases
- Faded blue color HOT 1
- Warlus in python substitution: NamedExpr target must be a Name
- Edge case: `TERM=dumb xonsh -i` hangs indefinitely if stdin is non-interactive
- Edge case: `xonsh --no-rc --no-env`: `TERM environment variable not set`
- Main branch regress: redirect to python substitution HOT 3
- Windows: case of commands is incorrectly upper-cased on Windows HOT 7
- Completion: `act, _, value = act_res`: `Exception too many values to unpack (expected 3)` HOT 1
- Windows: Don't imply PATH=. HOT 7
- Edge case: `source file.xonshrc` shows `attempting to source non-xonsh file`
- Disable loading xonshrc in xonsh pytest plugin HOT 1
- Unintended loading `xonshrc` file in script mode HOT 15
- Colorize stderr
- Windows: support windows paths in environment HOT 1
- Refactoring: review interactive functionality
- Macs and Next don't have a login shell HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xonsh.