[2.18][PATCH 0/6] Patch review
Please review this set of changes for wrynose and have comments back by end of day Tuesday, September 29.
Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/valkyrie/?#/builders/29/builds/4811
The following changes since commit 84a8d046593840df460c1312365031c817eb8918:
tests/fetch: Drop ftp checkstatus test (2026-09-14 23:00:27 +0200)
are available in the Git repository at:
https://git.openembedded.org/bitbake-contrib stable/2.18-review
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.18-review
for you to fetch changes up to a8b1dd0aa61ad91716379cdad59c4a9206ebfd7f:
asyncrpc: Close the client event loop when the client is collected (2026-09-23 15:55:35 +0200)
----------------------------------------------------------------
Chris Laplante (3):
runqueue: Fix pending_hash_index not including taskname
runqueue: fix bad check in process_possible_migrations
runqueue: wait for covered tasks before setscene
Francisco Pedraza (1):
asyncrpc: Close the client event loop when the client is collected
Richard Purdie (2):
fetch/wget: Handle long filenames correctly
data: Fix expandKeys recursion issue
lib/bb/asyncrpc/client.py | 50 ++++++++++++++++++++++++++++++++++++--- lib/bb/data.py | 2 +- lib/bb/data_smart.py | 5 ++-- lib/bb/fetch2/wget.py | 7 ++++-- lib/bb/runqueue.py | 9 ++++--- lib/bb/tests/data.py | 25 ++++++++++++++++++++ 6 files changed, 85 insertions(+), 13 deletions(-)
[bitbake][wrynose][2.18][PATCH 1/6] runqueue: Fix pending_hash_index not including taskname
From: Chris Laplante <[email protected]>
The intention was probably not to use the literal string, "taskname"
--- lib/bb/runqueue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/runqueue.py +1 -1
@@ -84,7 +84,7 @@ def pending_hash_index(tid, rqdata): (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) pn = rqdata.dataCaches[mc].pkg_fn[taskfn] h = rqdata.runtaskentries[tid].unihash - return pn + ":" + "taskname" + h + return pn + ":" + taskname + h class RunQueueStats: """
[bitbake][wrynose][2.18][PATCH 2/6] runqueue: fix bad check in process_possible_migrations
In reply to Yoann CongalFrom: Chris Laplante <[email protected]>
This was probably a copy-paste error from above. Detected by PyCharm's code analysis (Local variable p might be referenced before assignment).
--- lib/bb/runqueue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/runqueue.py +1 -1
@@ -2610,7 +2610,7 @@ class RunQueueExecute: next = set() ready = {} for tid in current: - if self.rqdata.runtaskentries[p].depends and not self.rqdata.runtaskentries[tid].depends.isdisjoint(total): + if self.rqdata.runtaskentries[tid].depends and not self.rqdata.runtaskentries[tid].depends.isdisjoint(total): continue # get_taskhash for a given tid *must* be called before get_unihash* below ready[tid] = bb.parse.siggen.get_taskhash(tid, self.rqdata.runtaskentries[tid].depends, self.rqdata.dataCaches)
[bitbake][wrynose][2.18][PATCH 4/6] fetch/wget: Handle long filenames correctly
In reply to Yoann CongalFrom: Richard Purdie <[email protected]>
Long filenames, which may happen through sstate, were being handled incorrectly as they could exceed max path lengths when '.tmp' was added.
Handle those cases by using slightly shorter filenames if that happens for the intermediate tmp file.
[YOCTO #16293]
--- lib/bb/fetch2/wget.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/bb/fetch2/wget.py +5 -2
@@ -105,7 +105,10 @@ class Wget(FetchMethod): fetchcmd = self.basecmd dldir = os.path.realpath(d.getVar("DL_DIR")) - localpath = os.path.join(dldir, ud.localfile) + ".tmp" + # Where we ultimately want the file + finalpath = os.path.join(dldir, ud.localfile) + # A temp location while processing, keeping in mind max path lengths + localpath = finalpath[:250] + ".tmp" bb.utils.mkdirhier(os.path.dirname(localpath)) fetchcmd += " --output-document=%s" % shlex.quote(localpath)
@@ -142,7 +145,7 @@ class Wget(FetchMethod): # Remove the ".tmp" and move the file into position atomically # Our lock prevents multiple writers but mirroring code may grab incomplete files - os.rename(localpath, localpath[:-4]) + os.rename(localpath, finalpath) return True
[bitbake][wrynose][2.18][PATCH 6/6] asyncrpc: Close the client event loop when the client is collected
In reply to Yoann CongalFrom: Francisco Pedraza <[email protected]>
Client creates its own event loop and installs it with asyncio.set_event_loop(), so a client dropped without close() being called keeps the loop, and any transport that loop owns, alive. The loop only becomes collectable once a later client replaces the global reference, and asyncio then reports the transport and the loop as unclosed:
ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object>
ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False>
This is why the warning shows up at an unrelated later point rather than where the client was leaked.
SignatureGeneratorUniHashMixIn caches its client and only closes it from reset() and exit(), so any teardown path missing those leaks it.
Register a weakref.finalize() to close the loop when the client is collected. close() detaches the finalizer first, so the explicit path does the same work as before.
Shutdown errors are logged rather than raised, since an exception from the finalizer would otherwise be discarded by the interpreter and reported only as "Exception ignored in". A peer that has gone away or stopped responding is expected for a client that was never closed and is logged at debug; anything else, including a loop that cannot be run, is logged at warning. The exceptions raised by websockets fall into the latter case as they cannot be named here, websockets being imported lazily in connect_websocket(). The loop is closed in every case.
Reproduced with two clients where the first is never closed, on python 3.10 with websockets 10.4 and on python 3.14 with websockets 17.0.1. Both report the warnings without this change and neither does with it. Each handled exception type was checked to not escape the finalizer, to still close the loop and to log at the intended level. bitbake-selftest hashserv.tests passes.
Fixes [YOCTO #16236]
--- lib/bb/asyncrpc/client.py | 50 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-)
lib/bb/asyncrpc/client.py +47 -3
@@ -7,15 +7,19 @@ import abc import asyncio import json +import logging import os import socket import sys import re import contextlib +import weakref from threading import Thread from .connection import StreamConnection, WebsocketConnection, DEFAULT_MAX_CHUNK from .exceptions import ConnectionClosedError, InvokeError +logger = logging.getLogger("bb.asyncrpc.client") + UNIX_PREFIX = "unix://" WS_PREFIX = "ws://" WSS_PREFIX = "wss://"
@@ -224,8 +228,49 @@ class Client(object): # required (but harmless) with it. asyncio.set_event_loop(self.loop) + # The loop and its transports must be closed even if the caller never + # calls close(). Since set_event_loop() above replaces the reference + # held by the previous client, an unclosed loop only becomes reachable + # for collection once another client is created, at which point + # asyncio reports "unclosed transport" and "unclosed event loop" + # ResourceWarnings. The finalizer is detached by close() so that the + # normal path is unaffected. + self._finalizer = weakref.finalize( + self, self._close_loop, self.loop, self.client + ) + self._add_methods("connect_tcp", "ping") + @staticmethod + def _close_loop(loop, client): + if loop.is_closed(): + return + try: + loop.run_until_complete(client.close()) + loop.run_until_complete(loop.shutdown_asyncgens()) + # This can be called from the finalizer, where an exception would be + # discarded by the interpreter and reported only as "Exception ignored + # in", so report the error here instead. The loop is closed below in + # every case. + except (OSError, ConnectionClosedError, asyncio.TimeoutError) as exc: + # The peer has gone away or is not responding. That is expected + # for a client that was never closed, so it is not worth warning + # about. asyncio.TimeoutError is only distinct from OSError on + # python older than 3.11. + logger.debug("Client connection already closed or unreachable: %s" % exc) + except RuntimeError as exc: + # The loop could not be run, for example because another loop is + # already running in this thread. Unlike the above, this means + # something is wrong with how the client is being used. + logger.warning("Could not shut down client event loop: %s" % exc) + except Exception as exc: + # Also covers the exceptions raised by websockets, which cannot be + # named here as it is imported lazily in connect_websocket(), and + # whatever may be raised while the interpreter is shutting down. + logger.warning("Error shutting down client connection: %s" % exc) + finally: + loop.close() + @abc.abstractmethod def _get_async_client(self): pass
@@ -258,9 +303,8 @@ class Client(object): def close(self): if self.loop: - self.loop.run_until_complete(self.client.close()) - self.loop.run_until_complete(self.loop.shutdown_asyncgens()) - self.loop.close() + self._finalizer.detach() + self._close_loop(self.loop, self.client) self.loop = None def __enter__(self):
[bitbake][wrynose][2.18][PATCH 3/6] runqueue: wait for covered tasks before setscene
In reply to Yoann CongalFrom: Chris Laplante <[email protected]>
The existing continue only affected the inner loop, allowing setscene execution while covered tasks were still running. Check the collection directly so candidate selection waits as intended.
AI-Generated: GPT-5.6 Sol
--- lib/bb/runqueue.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/bb/runqueue.py +2 -3
@@ -2250,9 +2250,8 @@ class RunQueueExecute: return True continue # If covered tasks are running, need to wait for them to complete - for t in self.sqdata.sq_covered_tasks[nexttask]: - if t in self.runq_running and t not in self.runq_complete: - continue + if any(t in self.runq_running and t not in self.runq_complete for t in self.sqdata.sq_covered_tasks[nexttask]): + continue if nexttask in self.sq_deferred: # Deferred tasks that were still deferred were skipped above so we now need to process logger.debug("Task %s no longer deferred" % nexttask)
[bitbake][wrynose][2.18][PATCH 5/6] data: Fix expandKeys recursion issue
In reply to Yoann CongalFrom: Richard Purdie <[email protected]>
Using an variable expansion in override such as:
RDEPENDS:${PN}:append:pn-packagegroup-cross-canadian-${MACHINE} = ' XXX'
wasn't functioning correctly. Looking through the code, renameVar does work correctly but it doesn't work if called multiple times on the sub components of the variable.
expandKeys will already recurse variables so we need to ensure renameVar doesn't also do that as things break if we do it multiple times.
Change the code to avoid recursion in renameVar which should also have a small performance improvement.
Test case from Nguyen Minh Tien <[email protected]>
[YOCTO #14867]
--- lib/bb/data.py | 2 +- lib/bb/data_smart.py | 5 +++-- lib/bb/tests/data.py | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-)
lib/bb/data.py +1 -1
@@ -94,7 +94,7 @@ def expandKeys(alterdata, readdata = None): val = alterdata.getVar(key, False) if val is not None: bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)) - alterdata.renameVar(key, ekey) + alterdata.renameVar(key, ekey, recurse=False) def inheritFromOS(d, savedenv, permitted): """Inherit variables from the initial environment."""
lib/bb/data_smart.py +3 -2
@@ -661,7 +661,7 @@ class DataSmart(MutableMapping): def getVar(self, var, expand=True, noweakdefault=False, parsing=False): return self.getVarFlag(var, "_content", expand, noweakdefault, parsing) - def renameVar(self, key, newkey, **loginfo): + def renameVar(self, key, newkey, recurse=True, **loginfo): """ Rename the variable key to newkey """
@@ -693,7 +693,8 @@ class DataSmart(MutableMapping): self.overridedata[newkey] = [] for (v, o) in self.overridedata[key]: self.overridedata[newkey].append([v.replace(key, newkey), o]) - self.renameVar(v, v.replace(key, newkey)) + if recurse: + self.renameVar(v, v.replace(key, newkey)) if ':' in newkey and val is None: self._setvar_update_overrides(newkey, **loginfo)
lib/bb/tests/data.py +25 -0
@@ -406,6 +406,31 @@ class TestOverrides(unittest.TestCase): bb.data.expandKeys(self.d) self.assertEqual(self.d.getVar("VERSION"), "2") + # Test an :append whose override name is only resolved by key expansion + def test_append_in_expanded_override(self): + self.d.setVar("MACHINE", "qemux86") + self.d.setVar("PN", "gizmo") + self.d.setVar("OVERRIDES", "gizmo:pn-gizmo-qemux86") + self.d.setVar("TEST:${PN}", "base") + self.d.setVar("TEST:${PN}:append:pn-gizmo-${MACHINE}", " appended") + bb.data.expandKeys(self.d) + self.assertEqual(self.d.getVar("TEST"), "base appended") + + # Test renaming to a key which is itself not expanded yet, as native.bbclass + # does. The dependent override keys must be left for expandKeys() to rename. + def test_rename_to_unexpanded_key_with_override(self): + self.d.setVar("BPN", "gizmo") + self.d.setVar("PN", "gizmo-native") + self.d.setVar("OVERRIDES", "class-target") + self.d.setVar("TEST:${PN}-lib", "base") + self.d.setVar("TEST:${PN}-lib:class-target", "target") + with LogRecord() as logs: + self.d.renameVar("TEST:${PN}-lib", "TEST:${BPN}-lib-native") + bb.data.expandKeys(self.d) + self.assertFalse(logContains("renameVar with equivalent keys", logs)) + self.assertFalse(logContains("replaces original key", logs)) + self.assertEqual(self.d.getVar("TEST:gizmo-lib-native"), "target") + def test_remove_with_override(self): self.d.setVar("TEST:bar", "testvalue2") self.d.setVar("TEST:some_val", "testvalue3 testvalue5")
Re: [bitbake-devel] [bitbake][wrynose][2.18][PATCH 5/6] data: Fix expandKeys recursion issue
Hi Yoann
Quoted 14 lines · Yoann Congal via lists.openembedded.org
From: Richard Purdie <[email protected]>
Using an variable expansion in override such as:
RDEPENDS:${PN}:append:pn-packagegroup-cross-canadian-${MACHINE} = ' XXX'
wasn't functioning correctly. Looking through the code, renameVar does work correctly but it doesn't work if called multiple times on the sub components of the variable.
expandKeys will already recurse variables so we need to ensure renameVar doesn't also do that as things break if we do it multiple times.
Quoted 6 lines
Change the code to avoid recursion in renameVar which should also have a small performance improvement.
Test case from Nguyen Minh Tien <[email protected]>
[YOCTO #14867]
This would require the oe-core change 7944665886 ("recipe_sanity: Drop rename overwrite detection") to be picked as well otherwise it leads to errors for layers using the class in wrynose.
I've sent a backport request.
Thanks,
Anuj
Quoted 93 lines
Signed-off-by Richard Purdie <[email protected]>Signed-off-by Mathieu Dubois-Briand <[email protected]>Signed-off-by Richard Purdie <[email protected]>(cherry picked from commit a3c6a020da9a352d0474e85bc0591b4a174cb0c0)Signed-off-by Yoann Congal <[email protected]>--- lib/bb/data.py | 2 +- lib/bb/data_smart.py | 5 +++-- lib/bb/tests/data.py | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-)lib/bb/data.py +1
-1@@ -94,7 +94,7 @@ def expandKeys(alterdata, readdata = None): val = alterdata.getVar(key, False) if val is not None: bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)) - alterdata.renameVar(key, ekey) + alterdata.renameVar(key, ekey, recurse=False) def inheritFromOS(d, savedenv, permitted): """Inherit variables from the initial environment."""lib/bb/data_smart.py +3
-2@@ -661,7 +661,7 @@ class DataSmart(MutableMapping): def getVar(self, var, expand=True, noweakdefault=False, parsing=False): return self.getVarFlag(var, "_content", expand, noweakdefault, parsing) - def renameVar(self, key, newkey, **loginfo): + def renameVar(self, key, newkey, recurse=True, **loginfo): """ Rename the variable key to newkey """@@ -693,7 +693,8 @@ class DataSmart(MutableMapping): self.overridedata[newkey] = [] for (v, o) in self.overridedata[key]: self.overridedata[newkey].append([v.replace(key, newkey), o]) - self.renameVar(v, v.replace(key, newkey)) + if recurse: + self.renameVar(v, v.replace(key, newkey)) if ':' in newkey and val is None: self._setvar_update_overrides(newkey, **loginfo)lib/bb/tests/data.py +25
-1@@ -406,6 +406,31 @@ class TestOverrides(unittest.TestCase): bb.data.expandKeys(self.d) self.assertEqual(self.d.getVar("VERSION"), "2") + # Test an :append whose override name is only resolved by key expansion + def test_append_in_expanded_override(self): + self.d.setVar("MACHINE", "qemux86") + self.d.setVar("PN", "gizmo") + self.d.setVar("OVERRIDES", "gizmo:pn-gizmo-qemux86") + self.d.setVar("TEST:${PN}", "base") + self.d.setVar("TEST:${PN}:append:pn-gizmo-${MACHINE}", " appended") + bb.data.expandKeys(self.d) + self.assertEqual(self.d.getVar("TEST"), "base appended") + + # Test renaming to a key which is itself not expanded yet, as native.bbclass + # does. The dependent override keys must be left for expandKeys() to rename. + def test_rename_to_unexpanded_key_with_override(self): + self.d.setVar("BPN", "gizmo") + self.d.setVar("PN", "gizmo-native") + self.d.setVar("OVERRIDES", "class-target") + self.d.setVar("TEST:${PN}-lib", "base") + self.d.setVar("TEST:${PN}-lib:class-target", "target") + with LogRecord() as logs: + self.d.renameVar("TEST:${PN}-lib", "TEST:${BPN}-lib-native") + bb.data.expandKeys(self.d) + self.assertFalse(logContains("renameVar with equivalent keys", logs)) + self.assertFalse(logContains("replaces original key", logs)) + self.assertEqual(self.d.getVar("TEST:gizmo-lib-native"), "target") + def test_remove_with_override(self): self.d.setVar("TEST:bar", "testvalue2") self.d.setVar("TEST:some_val", "testvalue3 testvalue5") -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#20264): https://lists.openembedded.org/g/bitbake-devel/message/20264
Mute This Topic: https://lists.openembedded.org/mt/121452884/3616702
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-