All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul Barker" <paul@pbarker.dev>
To: "Etienne Cordonnier" <ecordonnier@snap.com>,
	<bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH v2 1/2] fetch/wget: Have checkstatus() capture connection_cache, not fetch
Date: Tue, 17 Nov 2026 08:53:38 +0000	[thread overview]
Message-ID: <DMXCXTQOM1ZW.1OMQYIZFM1ZTV@pbarker.dev> (raw)
In-Reply-To: <CAHUKmYYpvYHaAbFVoBk7XJivpQet0G3wQ5or0BohNBMhMNH26A@mail.gmail.com>

On Mon Nov 16, 2026 at 7:51 PM GMT, Etienne Cordonnier wrote:
> Hi,
> is the patch OK? I see that it has been in master-next for a while. Is
> there some potential issue I should address?

Hi Étienne,

Unfortunately we have limited bandwidth for reviewing changes and there
is a lot of work in progress. Apologies that this got stuck in the
queue.

This patch looks fine, I will take a look at the second patch in the
series and give some feedback.

>
> On Mon, Sep 28, 2026 at 2:51 PM <ecordonnier@snap.com> wrote:
>
>> From: Etienne Cordonnier <ecordonnier@snap.com>
>>
>> checkstatus()'s nested handler classes referenced fetch.connection_cache,
>> so their methods closed over the fetch parameter itself rather than just
>> the connection cache. Capture connection_cache in a local variable instead
>> and use that everywhere. No behaviour change; this makes the next commit,
>> which caches the urllib opener built from these handlers, safe: a cached
>> opener's closures no longer keep the Fetch object that built it alive.
>>
>> AI-Generated: Uses Claude Code (Claude Opus 5.5)
>> Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
>> ---
>>  lib/bb/fetch/wget.py | 23 ++++++++++++-----------
>>  1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/lib/bb/fetch/wget.py b/lib/bb/fetch/wget.py
>> index 972c84048..fe2de25d3 100644
>> --- a/lib/bb/fetch/wget.py
>> +++ b/lib/bb/fetch/wget.py
>> @@ -178,23 +178,24 @@ class Wget(FetchMethod):
>>      def checkstatus(self, fetch, ud, d, try_again=True):
>>          check_certs = self.check_certs(d)
>>          newenv = bb.fetch.get_fetcher_environment(d)
>> +        connection_cache = fetch.connection_cache
>>
>>          class HTTPConnectionCache(http.client.HTTPConnection):
>>              def cache_id(self):
>>                  return None
>>
>> -            if fetch.connection_cache:
>> +            if connection_cache:
>>                  def connect(self):
>>                      """Connect to the host and port specified in
>> __init__."""
>>
>> -                    sock = fetch.connection_cache.get_connection(
>> +                    sock = connection_cache.get_connection(
>>                          self.host, self.port, self.cache_id())
>>                      if sock:
>>                          self.sock = sock
>>                      else:
>>                          self.sock = socket.create_connection((self.host,
>> self.port),
>>                                      self.timeout, self.source_address)
>> -                        fetch.connection_cache.add_connection(
>> +                        connection_cache.add_connection(
>>                              self.host, self.port, self.sock,
>> self.cache_id())
>>
>>                      if self._tunnel_host:
>> @@ -206,17 +207,17 @@ class Wget(FetchMethod):
>>                          newenv.get("SSL_CERT_FILE"),
>>                          self._tunnel_host, self._tunnel_port)
>>
>> -            if fetch.connection_cache:
>> +            if connection_cache:
>>                  def connect(self):
>>                      """Reuse an established TLS connection when
>> available."""
>>
>> -                    sock = fetch.connection_cache.get_connection(
>> +                    sock = connection_cache.get_connection(
>>                          self.host, self.port, self.cache_id())
>>                      if sock:
>>                          self.sock = sock
>>                      else:
>>                          super().connect()
>> -                        fetch.connection_cache.add_connection(
>> +                        connection_cache.add_connection(
>>                              self.host, self.port, self.sock,
>> self.cache_id())
>>
>>          class CacheHTTPHandler(urllib.request.HTTPHandler):
>> @@ -252,7 +253,7 @@ class Wget(FetchMethod):
>>                  # request.
>>
>>                  # Don't close connection when connection_cache is enabled,
>> -                if fetch.connection_cache is None:
>> +                if connection_cache is None:
>>                      headers["Connection"] = "close"
>>                  else:
>>                      headers["Connection"] = "Keep-Alive" # Works for
>> HTTP/1.0
>> @@ -282,8 +283,8 @@ class Wget(FetchMethod):
>>                      # with the dead connection removed from the cache.
>>                      # If it still fails, we give up, which can happen for
>> bad
>>                      # HTTP proxy settings.
>> -                    if fetch.connection_cache:
>> -                        fetch.connection_cache.remove_connection(
>> +                    if connection_cache:
>> +                        connection_cache.remove_connection(
>>                              h.host, h.port, h.cache_id())
>>                      h.close()
>>                      raise
>> @@ -316,9 +317,9 @@ class Wget(FetchMethod):
>>                  resp.msg = r.reason
>>
>>                  # Close connection when server request it.
>> -                if fetch.connection_cache is not None:
>> +                if connection_cache is not None:
>>                      if 'Connection' in r.msg and r.msg['Connection'] ==
>> 'close':
>> -                        fetch.connection_cache.remove_connection(
>> +                        connection_cache.remove_connection(
>>                              h.host, h.port, h.cache_id())
>>
>>                  return resp
>> --
>> 2.43.0
>>
>>



Best regards,

-- 
Paul Barker


  reply	other threads:[~2026-11-17  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 12:50 [PATCH v2 0/2] fetch/wget: Reuse the checkstatus() urllib opener ecordonnier
2026-09-28 12:50 ` [PATCH v2 1/2] fetch/wget: Have checkstatus() capture connection_cache, not fetch ecordonnier
2026-11-16 19:51   ` Etienne Cordonnier
2026-11-17  8:53     ` Paul Barker [this message]
2026-09-28 12:50 ` [PATCH v2 2/2] fetch/wget: Reuse the checkstatus() urllib opener ecordonnier
2026-11-17  8:58   ` Paul Barker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DMXCXTQOM1ZW.1OMQYIZFM1ZTV@pbarker.dev \
    --to=paul@pbarker.dev \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=ecordonnier@snap.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.