diff options
Diffstat (limited to 'bitbake/bin/bitbake-worker')
| -rwxr-xr-x | bitbake/bin/bitbake-worker | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index e8073f2ac3..d2b146a6a9 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
| @@ -9,6 +9,7 @@ import os | |||
| 9 | import sys | 9 | import sys |
| 10 | import warnings | 10 | import warnings |
| 11 | warnings.simplefilter("default") | 11 | warnings.simplefilter("default") |
| 12 | warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*use.of.fork.*may.lead.to.deadlocks.in.the.child.*") | ||
| 12 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) | 13 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) |
| 13 | from bb import fetch2 | 14 | from bb import fetch2 |
| 14 | import logging | 15 | import logging |
| @@ -21,9 +22,14 @@ import traceback | |||
| 21 | import queue | 22 | import queue |
| 22 | import shlex | 23 | import shlex |
| 23 | import subprocess | 24 | import subprocess |
| 25 | import fcntl | ||
| 24 | from multiprocessing import Lock | 26 | from multiprocessing import Lock |
| 25 | from threading import Thread | 27 | from threading import Thread |
| 26 | 28 | ||
| 29 | # Remove when we have a minimum of python 3.10 | ||
| 30 | if not hasattr(fcntl, 'F_SETPIPE_SZ'): | ||
| 31 | fcntl.F_SETPIPE_SZ = 1031 | ||
| 32 | |||
| 27 | bb.utils.check_system_locale() | 33 | bb.utils.check_system_locale() |
| 28 | 34 | ||
| 29 | # Users shouldn't be running this code directly | 35 | # Users shouldn't be running this code directly |
| @@ -44,7 +50,6 @@ if sys.argv[1].startswith("decafbadbad"): | |||
| 44 | # updates to log files for use with tail | 50 | # updates to log files for use with tail |
| 45 | try: | 51 | try: |
| 46 | if sys.stdout.name == '<stdout>': | 52 | if sys.stdout.name == '<stdout>': |
| 47 | import fcntl | ||
| 48 | fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) | 53 | fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) |
| 49 | fl |= os.O_SYNC | 54 | fl |= os.O_SYNC |
| 50 | fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl) | 55 | fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl) |
| @@ -56,6 +61,12 @@ logger = logging.getLogger("BitBake") | |||
| 56 | 61 | ||
| 57 | worker_pipe = sys.stdout.fileno() | 62 | worker_pipe = sys.stdout.fileno() |
| 58 | bb.utils.nonblockingfd(worker_pipe) | 63 | bb.utils.nonblockingfd(worker_pipe) |
| 64 | # Try to make the pipe buffers larger as it is much more efficient. If we can't | ||
| 65 | # e.g. out of buffer space (/proc/sys/fs/pipe-user-pages-soft) then just pass over. | ||
| 66 | try: | ||
| 67 | fcntl.fcntl(worker_pipe, fcntl.F_SETPIPE_SZ, 512 * 1024) | ||
| 68 | except: | ||
| 69 | pass | ||
| 59 | # Need to guard against multiprocessing being used in child processes | 70 | # Need to guard against multiprocessing being used in child processes |
| 60 | # and multiple processes trying to write to the parent at the same time | 71 | # and multiple processes trying to write to the parent at the same time |
| 61 | worker_pipe_lock = None | 72 | worker_pipe_lock = None |
| @@ -105,7 +116,7 @@ def worker_flush(worker_queue): | |||
| 105 | if not worker_queue.empty(): | 116 | if not worker_queue.empty(): |
| 106 | worker_queue_int.extend(worker_queue.get()) | 117 | worker_queue_int.extend(worker_queue.get()) |
| 107 | written = os.write(worker_pipe, worker_queue_int) | 118 | written = os.write(worker_pipe, worker_queue_int) |
| 108 | worker_queue_int = worker_queue_int[written:] | 119 | del worker_queue_int[0:written] |
| 109 | except (IOError, OSError) as e: | 120 | except (IOError, OSError) as e: |
| 110 | if e.errno != errno.EAGAIN and e.errno != errno.EPIPE: | 121 | if e.errno != errno.EAGAIN and e.errno != errno.EPIPE: |
| 111 | raise | 122 | raise |
| @@ -171,11 +182,8 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask): | |||
| 171 | elif workerdata["umask"]: | 182 | elif workerdata["umask"]: |
| 172 | umask = workerdata["umask"] | 183 | umask = workerdata["umask"] |
| 173 | if umask: | 184 | if umask: |
| 174 | # umask might come in as a number or text string.. | 185 | # Convert to a python numeric value as it could be a string |
| 175 | try: | 186 | umask = bb.utils.to_filemode(umask) |
| 176 | umask = int(umask, 8) | ||
| 177 | except TypeError: | ||
| 178 | pass | ||
| 179 | 187 | ||
| 180 | dry_run = cfg.dry_run or runtask['dry_run'] | 188 | dry_run = cfg.dry_run or runtask['dry_run'] |
| 181 | 189 | ||
| @@ -357,7 +365,7 @@ class runQueueWorkerPipe(): | |||
| 357 | def read(self): | 365 | def read(self): |
| 358 | start = len(self.queue) | 366 | start = len(self.queue) |
| 359 | try: | 367 | try: |
| 360 | self.queue.extend(self.input.read(102400) or b"") | 368 | self.queue.extend(self.input.read(512*1024) or b"") |
| 361 | except (OSError, IOError) as e: | 369 | except (OSError, IOError) as e: |
| 362 | if e.errno != errno.EAGAIN: | 370 | if e.errno != errno.EAGAIN: |
| 363 | raise | 371 | raise |
