<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/poky.git/bitbake/lib/bb/utils.py, branch scarthgap-5.0.15</title>
<subtitle>Mirror of git.yoctoproject.org/poky</subtitle>
<id>https://git.enea.com/cgit/linux/poky.git/atom?h=scarthgap-5.0.15</id>
<link rel='self' href='https://git.enea.com/cgit/linux/poky.git/atom?h=scarthgap-5.0.15'/>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/'/>
<updated>2025-09-17T22:36:44+00:00</updated>
<entry>
<title>bitbake: Use a "fork" multiprocessing context</title>
<updated>2025-09-17T22:36:44+00:00</updated>
<author>
<name>Joshua Watt</name>
<email>JPEWhacker@gmail.com</email>
</author>
<published>2025-08-21T22:40:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=f00c4968ff34c6a23f2467f310b5aae31ab4947c'/>
<id>urn:sha1:f00c4968ff34c6a23f2467f310b5aae31ab4947c</id>
<content type='text'>
Python 3.14 changes the default multiprocessing context from "fork" to
"forkserver"; however bitbake heavily relies on "fork" to efficiently
pass data to the child processes. As such, make "fork" context in the bb
namespace and use it in place of the normal multiprocessing module.

Note that multiprocessing contexts were added in Python 3.4, so this
should be safe to use even before Python 3.14

[YOCTO #15858]

(Bitbake rev: 15d7448e04aa78c827d2cef9eb1a62bd6e0dd119)

Signed-off-by: Joshua Watt &lt;JPEWhacker@gmail.com&gt;
Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
Signed-off-by: Martin Jansa &lt;martin.jansa@gmail.com&gt;
Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Optimise signal/sigmask performance</title>
<updated>2025-08-04T14:55:06+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2025-07-29T18:43:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=511d3e23f5e769e669f767759ea936f33b2106cd'/>
<id>urn:sha1:511d3e23f5e769e669f767759ea936f33b2106cd</id>
<content type='text'>
Running "time bitbake -pP idle" with a valid cache shows around 800,000
calls to enum creation from python's signal.py. We don't care about this
overhead and it adversely affects cache load time quite badly.

Try and use _signal directly, falling back to signal, which avoids
this overhead we don't need and makes cache loading much faster.

(Bitbake rev: 982645110a19ebb94d519926a4e14c8a2a205cfd)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
(cherry picked from commit ee5fce67ce35b025c68aa61e2e758903269ee346)
Signed-off-by: Chris Laplante &lt;chris.laplante@agilent.com&gt;
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: event/utils: Avoid deadlock from lock_timeout() and recursive events</title>
<updated>2025-03-15T13:40:07+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2025-03-03T12:57:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=83fda1bb2e132569b08b0028e5624bfaaa9a2a43'/>
<id>urn:sha1:83fda1bb2e132569b08b0028e5624bfaaa9a2a43</id>
<content type='text'>
We've been seeing intermittent failures on Ubuntu 22.04 in oe-selftest which
were problematic to debug. The failure was inside lock_timeout and once that was
identified and the backtrace obtained, the problem becomes clearer:

  File "X/bitbake/lib/bb/server/process.py", line 466, in idle_thread_internal
    retval = function(self, data, False)
  File "X/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
    self.cooker.updateCache()
  File "X/bitbake/lib/bb/cooker.py", line 1629, in updateCache
    self.parser = CookerParser(self, mcfilelist, total_masked)
  File "X/bitbake/lib/bb/cooker.py", line 2141, in __init__
    self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder, self.cfghash, cooker.caches_array)
  File "X/bitbake/lib/bb/cache.py", line 772, in __init__
    loaded += c.prepare_cache(progress)
  File "X/bitbake/lib/bb/cache.py", line 435, in prepare_cache
    loaded = self.load_cachefile(progress)
  File "X/bitbake/lib/bb/cache.py", line 516, in load_cachefile
    progress(cachefile.tell() + previous_progress)
  File "X/bitbake/lib/bb/cache.py", line 751, in progress
    bb.event.fire(bb.event.CacheLoadProgress(current_progress, cachesize),
  File "X/bitbake/lib/bb/event.py", line 234, in fire
    fire_ui_handlers(event, d)
  File "X/bitbake/lib/bb/event.py", line 210, in fire_ui_handlers
    _ui_handlers[h].event.send(event)
  File "X/bitbake/lib/bb/cooker.py", line 117, in send
    str_event = codecs.encode(pickle.dumps(event), \'base64\').decode(\'utf-8\')
  File "/usr/lib/python3.10/asyncio/sslproto.py", line 320, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  File "/usr/lib/python3.10/warnings.py", line 109, in _showwarnmsg
    sw(msg.message, msg.category, msg.filename, msg.lineno,
  File "X/bitbake/lib/bb/main.py", line 113, in _showwarning
    warnlog.warning(s)
  File "/usr/lib/python3.10/logging/__init__.py", line 1489, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.10/logging/__init__.py", line 1624, in _log
    self.handle(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 1634, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 1696, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 968, in handle
    self.emit(record)
  File "X/bitbake/lib/bb/event.py", line 778, in emit
    fire(record, None)
  File "X/bitbake/lib/bb/event.py", line 234, in fire
    fire_ui_handlers(event, d)
  File "X/bitbake/lib/bb/event.py", line 197, in fire_ui_handlers
    with bb.utils.lock_timeout(_thread_lock):
  File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "X/bitbake/lib/bb/utils.py", line 1888, in lock_timeout
    bb.server.process.serverlog("Couldn\'t get the lock for 5 mins, timed out, exiting. %s" % traceback.format_stack())

or put in simpler terms, whilst sending an event(), an unrelated warning
message happens to be triggered from asyncio:

/usr/lib/python3.10/asyncio/sslproto.py:320: ResourceWarning: unclosed transport &lt;asyncio.sslproto._SSLProtocolTransport object at 0x7f0e797d3100&gt;

which triggers a second event() which can't be sent as we're already
in the critcal section and already hold the lock.

That warning is due to the version of asyncio used on Ubuntu 22.04 with
python 3.10 and that comined with timing issues explains why we don't
see it on other python versions or distros.

We can't handle the second event as the lock is there to serialise the
events. Instead, we queue the event and then process the queue later.

Add a new version of lock_timeout which allows us to handle the situation
more gracefully.

(Bitbake rev: 696c2c1ef095f8b11c7d2eff36fae50f58c62e5e)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
(cherry picked from commit 2c590ff1aff89d23b25ce808650f200013a1e6af)
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Add signal blocking for lock_timeout</title>
<updated>2025-03-15T13:40:07+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2025-03-03T11:58:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=7eea22a7cdb28792f6e76823558dff8de9f2f039'/>
<id>urn:sha1:7eea22a7cdb28792f6e76823558dff8de9f2f039</id>
<content type='text'>
We never want to exit whilst holding these locks as it deadlocks all python
threads. Add signal blocking around the lock critical part so a signal
shouldn't cause such an exit.

(Bitbake rev: 5cc1dde1ffd9382b3a9e4cc182be067defba16a7)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
(cherry picked from commit a097755c671e2b530dea6200a94b39fa9dca246c)
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Tweak lock_timeout logic</title>
<updated>2025-03-15T13:40:07+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2025-03-03T11:56:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=798513440976cc9729b52a4f5ac00238dd642ef8'/>
<id>urn:sha1:798513440976cc9729b52a4f5ac00238dd642ef8</id>
<content type='text'>
We should really try and take the lock in the try/finally block so that
in some rare cases such as badly timed interrupt/signal, we always release
the lock.

(Bitbake rev: 5dbbca616a71047fc3573a2be49846d5c9cdd15a)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
(cherry picked from commit a9eb8bf7174b6962b5ba07192fe95b8c7112d9d2)
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Print information about lock issue before exiting</title>
<updated>2025-03-15T13:40:07+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2025-03-03T11:55:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=e9aa48f80719bb847ec1a6fb01895223ab47489e'/>
<id>urn:sha1:e9aa48f80719bb847ec1a6fb01895223ab47489e</id>
<content type='text'>
(Bitbake rev: d41fad7fadde59dd63647bbbeb074604314bf310)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
(cherry picked from commit cdf6c51a064f8f335c3262b7f102618996f1a229)
Signed-off-by: Steve Sakoman &lt;steve@sakoman.com&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: better estimate number of available cpus</title>
<updated>2024-03-22T16:26:45+00:00</updated>
<author>
<name>Felix Moessbauer</name>
<email>felix.moessbauer@siemens.com</email>
</author>
<published>2024-03-13T10:06:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=9504df41f9e1c64014436a46abf058c5d3f42d3f'/>
<id>urn:sha1:9504df41f9e1c64014436a46abf058c5d3f42d3f</id>
<content type='text'>
When running in a cgroup which is limited to a subset of cpus (via
cpuset.cpus), cpu_count() should return the number of cpus that can be
used instead of the number of cpus the system has.

This also aligns the semantics with nproc.

(Bitbake rev: a029bfe96c6542f178720c72a772b7ede9898118)

Signed-off-by: Felix Moessbauer &lt;felix.moessbauer@siemens.com&gt;
Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: remove BB_ENV_PASSTHROUGH from preserved_envvars()</title>
<updated>2024-03-05T12:25:08+00:00</updated>
<author>
<name>Michael Opdenacker</name>
<email>michael.opdenacker@bootlin.com</email>
</author>
<published>2024-03-04T14:01:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=be10de34231d2b0081aa0ff7cbc36aef110d7fee'/>
<id>urn:sha1:be10de34231d2b0081aa0ff7cbc36aef110d7fee</id>
<content type='text'>
preserved_envvars() is used when the BB_ENV_PASSTHROUGH
environment variable is not set. Therefore, its code shouldn't
return this variable.

(Bitbake rev: 0a33b560233b983456178541603ab96fea22238b)

Signed-off-by: Michael Opdenacker &lt;michael.opdenacker@bootlin.com&gt;
Reported-by: Robert P. J. Day &lt;rpjday@crashcourse.ca&gt;
Tested-by: Michael Opdenacker &lt;michael.opdenacker@bootlin.com&gt;
Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Fix mkdir with PosixPath</title>
<updated>2023-12-17T19:07:21+00:00</updated>
<author>
<name>Richard Purdie</name>
<email>richard.purdie@linuxfoundation.org</email>
</author>
<published>2023-12-17T13:11:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=e706249f7b68fdb57b8400d5d09ac4555a0868b5'/>
<id>urn:sha1:e706249f7b68fdb57b8400d5d09ac4555a0868b5</id>
<content type='text'>
Avoid:
    Exception: AttributeError: 'PosixPath' object has no attribute 'find'

(Bitbake rev: 0b37fe89ba12549109905b6d0e6d07d342162436)

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>bitbake: utils: Do not create directories with ${ in the name</title>
<updated>2023-12-08T17:17:42+00:00</updated>
<author>
<name>Pavel Zhukov</name>
<email>pavel@zhukoff.net</email>
</author>
<published>2023-12-08T11:37:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/linux/poky.git/commit/?id=d14eb12deb625e6644c0e727c336ad6bfafd0793'/>
<id>urn:sha1:d14eb12deb625e6644c0e727c336ad6bfafd0793</id>
<content type='text'>
In some cases ${ may not be expanded in the WORKDIR (one of the cases is
undefined variable) and causes cryptic failures [1]. Guard this by
erroring out if directory name contains ${

Fixes: [Yocto #15255]

[1]
ERROR: x-native-1.0+${SRCPV}-r0 do_deploy_source_date_epoch: Error executing a python function in exec_func_python() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: &lt;module&gt;
     0001:
 *** 0002:sstate_hardcode_path(d)
     0003:
File: '/home/mischief/src/poky/meta/classes-global/sstate.bbclass', lineno: 654, function: sstate_hardcode_path
     0650:    bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd))
     0651:    subprocess.check_output(sstate_hardcode_cmd, shell=True, cwd=sstate_builddir)
     0652:
     0653:        # If the fixmefn is empty, remove it..
 *** 0654:    if os.stat(fixmefn).st_size == 0:
     0655:        os.remove(fixmefn)
     0656:    else:
     0657:        bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd))
     0658:        subprocess.check_output(sstate_filelist_relative_cmd, shell=True)
Exception: FileNotFoundError: [Errno 2] No such file or directory: '/home/mischief/src/poky/build/tmp/work/core2-64-poky-linux/x-native/1.0+${SRCPV}-r0/sstate-build-deploy_source_date_epoch/fixmepath'

(Bitbake rev: e91c256ec076e70cf8a18e369fe7862e50618c48)

Signed-off-by: Pavel Zhukov &lt;pavel@zhukoff.net&gt;
Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
</content>
</entry>
</feed>
