<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Use python 'with' statement to make cleanup more robust and minor code cleaning"
   href="https://bugs.webkit.org/show_bug.cgi?id=147800#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Use python 'with' statement to make cleanup more robust and minor code cleaning"
   href="https://bugs.webkit.org/show_bug.cgi?id=147800">bug 147800</a>
              from <span class="vcard"><a class="email" href="mailto:dewei_zhu&#64;apple.com" title="dewei_zhu&#64;apple.com">dewei_zhu&#64;apple.com</a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=258543&amp;action=diff" name="attach_258543" title="Patch">attachment 258543</a> <a href="attachment.cgi?id=258543&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=258543&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=258543&amp;action=review</a>

<span class="quote">&gt;&gt;&gt;&gt; Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py:108
&gt;&gt;&gt;&gt;                      result = self._http_server_driver.fetch_result()
&gt;&gt;&gt; 
&gt;&gt;&gt; It looks like _browser_driver is not accessed anywhere else so I don't think it needs to be be on _runner at all.
&gt;&gt;&gt; Ideally, I'd like see the code like this here:
&gt;&gt;&gt; 
&gt;&gt;&gt; with TestEnvironment(benchmark) as env, timeout(self._plan['timeout'])
&gt;&gt;&gt;     result = env.fetch_results()
&gt;&gt; 
&gt;&gt; Browser driver is specified by platform and browser which are provided by the parameter of BenchmarkRunner.__init__. The solution I can think of currently is storing those values in a structure, and supplying this structure as  parameter of TextEnvironment.__init__ . Does that sounds good?
&gt; 
&gt; In that case, I don't think we want test_environment object all.
&gt; It's better for both browser_driver and http_server_driver to independently implement __enter__ and __exit__ (without a wrapper class)
&gt; so that we can directly instantiate those classes in this function.
&gt; Otherwise, the extra data structures and abstractions will only increase the code complexity.</span >

Yes, we should avoid introducing unnecessary abstractions. The problem with both browser_driver and http_server is that they are instantiated by the factory function, are we expecting something like &quot;with BrowserDriverFactory.create(....), HttpServerDriverFactory.create(....): &quot;?</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>