title: How to ignore exceptions occuring within a call to rglob?
body: <p>I am using <code>pathlib.Path.rglob</code> to browse through some files in a directory hierarchy. However one of the (sub-sub-...) directory cannot be parsed and an exception is thrown.</p>
  
  <pre><code>import pathlib
  for file in pathlib.Path(r'\\path\to\shared\folder').rglob('*.foo'):
    pass
  # OSError: [WinError 59] An unexpected network error occurred
  </code></pre>
  
  <p>Catching the exception in the body of the <code>for</code> loop makes no sense as the exeption occurs in <code>rglob</code>. Putting the entire loop within a <code>try</code> block does catch the exception, but then I cannot resume the computation.</p>
  
  <p>Does anybody have a clue about how to do that with <code>pathlib.Path.rglob</code>? A work around is to use good old <code>os.walk</code> but I would be interested in knowing a solution for this supposedly more modern tool.</p>