[merge] MVC progress bars, and indication of network traffic

Martin Pool mbp at canonical.com
Thu Dec 18 00:37:39 GMT 2008


On 17 Dec 2008, John Arbash Meinel <john at arbash-meinel.com> wrote:
> >     martin>          :param relpath: The relative path to the file
> >     martin>          """
> >     martin> -        return self.get(relpath).read()
> >     martin> +        f = self.get(relpath)
> >     martin> +        try:
> >     martin> +            return f.read()
> >     martin> +        finally:
> >     martin> +            f.close()
> > 
> > 
> > EErk ! I'm pretty sure you just closed the http socket here (the
> > http transport doesn't redefine get_bytes) ! If no test is
> > failing there, we need one. On the other hand, I'm not sure you
> > need that part in your patch.
> > 
> 
> Unless something has changed, HTTPTransport.get() does:
> 
> code, response_file = self._get(relpath, None)
> # FIXME: some callers want an iterable... One step forward, three steps
> # backwards :-/ And not only an iterable, but an iterable that can be
> # seeked backwards, so we will never be able to do that.  One such
> # known client is bzrlib.bundle.serializer.v4.get_bundle_reader. At the
> # time of this writing it's even the only known client -- vila20071203
>   return StringIO(response_file.read())
> 
> Mostly I'm pointing that we don't return the raw socket, we wrap it in a
> StringIO.

I'm glad you caught this, but I think we do need to be more clear about
whether the caller is or is not supposed to call close on the file
returned from get().  It seems to me that doing so should mean "I'm done
with this logical file", and this should not rely on them knowing how
the underlying transport implements it.
-- 
Martin



More information about the bazaar mailing list