New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(async): avoid blocking the shell while waiting #12304
Conversation
Due to "builtin echo $handler", _omz_async_callback was called immediately, as there was data to read on the pipe. Then the shell was blocked until the end of the async prompt handler. We now use associative array to get the handler name from the fd. For an unknown reason, the async child can block when launching a subshell, especially if there are several handlers registered. Using a function to set the return code avoids the issue, and is much faster. Fixes ohmyzsh#12290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks fast and snappy, and works well with 5.0.8. LGTM!
Thanks Loïc! |
@mcornella You squashed, so the fork improvements are in the same commit as the bugfix, and there is no comment any more (there is still the PR, but...). I didn't know there was a way to search in the keys of IIRC, the |
Co-authored-by: Marc Cornellà <marc@mcornella.com>
* upstream/master: Update README for git-prompt to clarify how to use (ohmyzsh#10922) fix(autojump): add macOS 'pkgsrc' installation location (ohmyzsh#12329) fix(lib/git): fix detection of function use in prompt perf(async): avoid executing `true` if not required (ohmyzsh#12318) fix(git): disable locally `ksharrays` fix(archlinux): make `upgrade` work with non-english feat(git): implement async completion for `git_prompt_status` (ohmyzsh#12319) feat(git)!: enable async git prompt (now for real) fix(async): avoid blocking the shell while waiting (ohmyzsh#12304) feat(httpie): complete https command (ohmyzsh#12314) feat(gcloud): add homebrew installation path (ohmyzsh#12308) fix(starship): keep `ZSH_THEME` if not installed (ohmyzsh#12309) style: remove trailing whitespace (ohmyzsh#12303) fix(poetry-env): activate only if env exists (ohmyzsh#12301) feat(terraform): add `tft` (`terraform test`) (ohmyzsh#12299) feat(jira): add help/usage cmd (ohmyzsh#12293) fix(ssh-agent): don't start new agent if screen/tmux symlink exists (ohmyzsh#12297)
Co-authored-by: Marc Cornellà <marc@mcornella.com>
Co-authored-by: Marc Cornellà <marc@mcornella.com>
Standards checklist:
Changes:
_omz_async_callback
is only called when the handler writes data (at the end), instead of just after the fork : it blocked the shell until the end of the async prompt handlerOther comments:
This is draft for now, as I cannot explain why the subshell could sometimes block for several seconds (which blocked the shell in
_omz_async_callback
).Even when it didn't block, the subshell was 10-20ms slower anyway.