zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org, gak@klanderman.net
Subject: Tests of interrupting completion, and completion_nostat_dirs
Date: Wed, 29 Jan 2014 18:12:06 -0800	[thread overview]
Message-ID: <140129181206.ZM22813@torch.brasslantern.com> (raw)
In-Reply-To: <87eh3q3g63.fsf@lwm.klanderman.net>

[> workers]

On Jan 29, 11:29am, Greg Klanderman wrote:
} Subject: Re: [Feature suggestion] (user configurable) timeout for generati
}
} >>>>> On January 25, 2014 Bart Schaefer <schaefer@brasslantern.com> wrote:
} 
} > On Jan 24,  9:46am, Greg Klanderman wrote:
} > }
} > } For slow completion due to calling out to a separate process for
} > } completions (_git comes to mind) if that is not currently
} > } interruptible it seems like there might be some hope of adding a
} > } timeout or ensuring C-c will interrupt.
} 
} > This is the thing I had a hard time reproducing.  Even if I force
} > the completion function to be very busy with a loop, I can interrupt
} > it.  (Oddly the value of $? is always 0 in _main_complete after I
} > hit ^C, so I can't detect the signal and issue a message.)

Incidentally, here's something I added to _main_complete to make this
easier to test:

------------
diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index d6831b8..036f1d3 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -126,6 +126,11 @@ fi
 
 _completer_num=1
 
+# We assume localtraps to be in effect here ...
+integer SECONDS=0
+trap 'zle -M "Killed by signal in ${funcstack[0]} after ${SECONDS}s";
+      zle -R; return 130' INT QUIT
+
 # Call the pre-functions.
 
 funcs=( "$compprefuncs[@]" )
------------

Any objection to that being pushed to the master git?

} Did you try a busy completion function, or external process?

I tried

    _slow() { sleep 30; return 1 }

and the infinite loop

    _slow() {
        while :; do read -E -k 1 -u 0 </dev/zero >/dev/null; done
        return 1
    }

and even

    _slow() {
        SECONDS=0
        while (( SECONDS < 30 )); do : ; done
        return 1
    }

and I was able to interrupt all of them.

} In the original post it seemed that the slow call was probably reading
} a large directory on a slow NFS mount.

Yes, but both that and stat of an automount are going to be disk-wait
blocking accesses to NFS.
 
} I'll attach the patch below, if you'd be willing to incorporate
} something like it let me know, I'd certainly prefer to have it part of
} zsh.  I would add documentation of course.

Hmm, to include this I'd probably want completion_nostat_dirs to be an
autoloaded parameter in the zsh/complete module or something like that.
It doesn't have any of those right now (the magic parameters that are
only valid inside completion widgets are a somewhat different beast) but
there's no reason it couldn't.

On the other hand ZLE_RPROMPT_INDENT is declared in the main shell even
though it's used only by zsh/zle ... anybody else want to weigh in?


       reply	other threads:[~2014-01-30  2:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CACcU-g0qb3gZVLPPS2bQBixuozSsXd_9ObK+V6CTcaP4qfiFtA@mail.gmail.com>
     [not found] ` <140122000435.ZM1516@torch.brasslantern.com>
     [not found]   ` <CADdV=MsdfHUKDVy1dLbZ-d19cAEpGuDxzsKPd3Cy6imJ1Lo_8Q@mail.gmail.com>
     [not found]     ` <140123171659.ZM19422@torch.brasslantern.com>
     [not found]       ` <87iot91lp8.fsf@lwm.klanderman.net>
     [not found]         ` <140125124934.ZM23767@torch.brasslantern.com>
     [not found]           ` <87eh3q3g63.fsf@lwm.klanderman.net>
2014-01-30  2:12             ` Bart Schaefer [this message]
2014-01-30  9:30               ` Peter Stephenson
2014-01-30 16:22                 ` Bart Schaefer
2014-02-03 15:04                   ` Greg Klanderman
2014-02-05  5:28                     ` Bart Schaefer
2014-02-05 13:56                       ` Greg Klanderman
2014-02-05 14:23                         ` Peter Stephenson
2014-02-05 17:15                           ` Bart Schaefer
2014-02-05 17:36                             ` Peter Stephenson
2014-02-11 15:11                               ` Greg Klanderman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=140129181206.ZM22813@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=gak@klanderman.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).