Fix ng-killall by swallowing psutil exceptions in filter

Review Request #4237 — Created Sept. 13, 2016 and submitted

3840, 3869
jsirois, kwlzn, zundel
ng-killall will fail to kill nailguns if there is a process earlier in the process list that has attributes that can't be accessed.

This patch wraps ProcessManager.process_iter's filter with a exception swallow call which allows it to continue if the filter calls a psutil error causing method.

Wrote unit tests exhibiting the behavior I was seeing and made them pass. Tried running ng-killall after the change and saw it work.

  1. God bless you! This has been driving me nuts.

  1. lgtm - thanks!

  2. src/python/pants/pantsd/ (Diff revision 1)

    not a big deal, but this naming stomps on the filter builtin - causes RB/IDEs/etc to highlight filter oddly.

    >>> filter
    <built-in function filter>
    1. Maybe even just collapse everything:

      with swallow_psutil_exceptions():  # process_iter may raise
        for proc in psutil.process_iter():
          with swallow_psutil_exceptions():  # proc_filter may raise
            if (proc_filter is None) or proc_filter(proc):
              yield proc
    2. That's much clearer.

  1. Ship It!
  2. ...subsequent processes will.
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as