<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - run-webkit-tests should trigger a spindump when WebContent process is unresponsive"
   href="https://bugs.webkit.org/show_bug.cgi?id=159827#c53">Comment # 53</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - run-webkit-tests should trigger a spindump when WebContent process is unresponsive"
   href="https://bugs.webkit.org/show_bug.cgi?id=159827">bug 159827</a>
              from <span class="vcard"><a class="email" href="mailto:jbedard&#64;apple.com" title="Jonathan Bedard &lt;jbedard&#64;apple.com&gt;"> <span class="fn">Jonathan Bedard</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=159827#c51">comment #51</a>)
<span class="quote">&gt; (In reply to <a href="show_bug.cgi?id=159827#c50">comment #50</a>)
&gt; &gt; Comment on <span class=""><a href="attachment.cgi?id=285120&amp;action=diff" name="attach_285120" title="Patch">attachment 285120</a> <a href="attachment.cgi?id=285120&amp;action=edit" title="Patch">[details]</a></span>
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; <a href="https://bugs.webkit.org/attachment.cgi?id=285120&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=285120&amp;action=review</a>
&gt; &gt; 
&gt; &gt; &gt;&gt; Tools/Scripts/webkitpy/port/ios.py:423
&gt; &gt; &gt;&gt; +            ], return_exit_code=True)
&gt; &gt; &gt; 
&gt; &gt; &gt; Notice that Executive.run_command() only throws a ScriptError exception if return_exit_code := False. It is good programming practice to limit the scope of a try-except to the minimum code that can raise an exception to help make it straightforward to debug the cause of an exception. In <a href="show_bug.cgi?id=159827#c25">comment #25</a> I gave an example of one way we can write this code such that we limit the scope of the try-except block.
&gt; &gt; 
&gt; &gt; This perhaps brings up another question, then, about sample_file_path(...),
&gt; &gt; which calls filesystem.join(...).  In the original sample_process code,
&gt; &gt; finding the report was in the try catch block, which is why I kept it there
&gt; &gt; after adding spindump.  If filesystem.join(...) throws an exception (or
&gt; &gt; results_directory(), actually), what is our desired functionality? 
&gt; 
&gt; Filesystem.join() does not raise an exception because it turns around and
&gt; calls os.path.join(). And I do not expect os.path.join() to raise an
&gt; exception because its documentation,
&gt; &lt;<a href="https://docs.python.org/2/library/os.path.html">https://docs.python.org/2/library/os.path.html</a>&gt;, as of 08/02 makes no
&gt; mention that it raises an exception.
&gt; 
&gt; &gt; I think for the time being, keeping the generation of the hang_report file path
&gt; &gt; inside the try-except block is prudent
&gt; 
&gt; Notice that the try-except block only catches a
&gt; webkitpy.common.system.executive.ScriptError exception. That is, it does not
&gt; catch a general-purpose Python Exception.
&gt; 
&gt; &gt; , as the tests can continue if an
&gt; &gt; error happens while attempting to generate either version of the crash
&gt; &gt; report, and 
&gt; 
&gt; &gt; it would seem unhelpful to be to have two try-except blocks in
&gt; &gt; this function. 
&gt; &gt; 
&gt; 
&gt; How did you come to the conclusion that we need to try-except blocks in this
&gt; function? Notice that I have exactly one try-except block in the example I
&gt; gave in <a href="show_bug.cgi?id=159827#c25">comment #25</a>.
&gt; 
&gt; As aforementioned above, the try-except block in sample_process() only
&gt; catches a webkitpy.common.system.executive.ScriptError exception. The
&gt; current code allows any other exception to bubble up. Maybe we should revise
&gt; this code to be more resilient to other kinds of exceptions. If so, such
&gt; consideration and work is more appropriate in a separate bug as the focus of
&gt; this bug is to add an enhancement to our sampling machinery: use spindump if
&gt; we can.</span >

(In reply to <a href="show_bug.cgi?id=159827#c52">comment #52</a>)
<span class="quote">&gt; (In reply to <a href="show_bug.cgi?id=159827#c51">comment #51</a>)
&gt; [...]
&gt; &gt; &gt; it would seem unhelpful to be to have two try-except blocks in
&gt; &gt; &gt; this function. 
&gt; &gt; &gt; 
&gt; &gt; 
&gt; &gt; How did you come to the conclusion that we need to try-except blocks in this function?
&gt; 
&gt; This should read:
&gt; 
&gt; How did you come to the conclusion that we need two try-except blocks in
&gt; this function?</span >

Sorry, I think my comment was not very clear.

What I was saying is that I kept the hang_report assignment in the try-except block because it had been in it's previous iteration, and I wasn't quite sure what kind of exceptions (if any) are thrown by sample_file_path(...) (as you point out, probably none, even when including results_directory()).  Essentially, I was trying to keep the same structure as had existed previously, and taking sample_file_path out of the try-except would have broken that pattern.

Since it does seem like sample_file_path(...) won't be throwing any exceptions, I will change this in the re-factor.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>