[AUH][PATCH v2 9/9] upgrade-helper.py: Limit number of requests to remote servers

<[email protected]>
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>
From: Daniel Turull <[email protected]>

In systems with lots of CPUs, we overflood some remote servers
and then we get timeouts because of rate control.

Be more conservative. Defaults to 8 parallel workers instead of 64.
Configurable via scan_workers=N in upgrade-helper.conf

For example, ftp.gnu.org was timing out

Assisted-by: Claude, Anthropic
Signed-off-by: Daniel Turull <[email protected]>
---
 upgrade-helper.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/upgrade-helper.py b/upgrade-helper.py
index 58fd660..11b8d58 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -808,9 +808,17 @@ class UniverseUpdater(Updater):
             return pkg_to_upgrade
 
         upgrade_pkggroups = []
+        scan_workers = int(settings.get("scan_workers", "8"))
 
         for layer_name, layer_recipes in self.recipes:
-            pkggroups_iter = oe.recipeutils.get_recipe_upgrade_status(layer_recipes)
+            # Limit parallel version checks to avoid overwhelming upstream
+            # servers (oe-core defaults to cpu_count which can be 64+).
+            _orig_cpu_count = oe.utils.cpu_count
+            oe.utils.cpu_count = lambda at_least=1, at_most=64: min(max(at_least, scan_workers), at_most)
+            try:
+                pkggroups_iter = oe.recipeutils.get_recipe_upgrade_status(layer_recipes)
+            finally:
+                oe.utils.cpu_count = _orig_cpu_count
 
             # Collect results, logging any fetch error that terminates
             # the iterator early (oe-core raises inside executor.map,
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.