diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-20 12:25:19 +0100 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-20 12:26:19 +0100 |
commit | 616e75523b0b1bbe730631dba70224b55cfaaa57 (patch) | |
tree | 2fd396d58386217135976c1747ddfde94b84e9f8 /bitbake | |
parent | 9708f9cba7923fa0b5a620e032ab3d9e085385a7 (diff) | |
download | poky-616e75523b0b1bbe730631dba70224b55cfaaa57.tar.gz |
bitbake: Correctly route events from the worker to the server
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/bitbake-runtask | 17 | ||||
-rw-r--r-- | bitbake/lib/bb/build.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/event.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/msg.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 2 |
5 files changed, 24 insertions, 8 deletions
diff --git a/bitbake/bin/bitbake-runtask b/bitbake/bin/bitbake-runtask index 417f3949cd..dee25cdf27 100755 --- a/bitbake/bin/bitbake-runtask +++ b/bitbake/bin/bitbake-runtask | |||
@@ -31,19 +31,26 @@ warnings.simplefilter("ignore", DeprecationWarning) | |||
31 | 31 | ||
32 | import bb.event | 32 | import bb.event |
33 | 33 | ||
34 | # Need to map our I/O correctly. Currently stdout is a pipe to | 34 | # Need to map our I/O correctly. stdout is a pipe to the server expecting |
35 | # the server expecting events. We save this and map stdout to stderr. | 35 | # events. We save this and then map stdout to stderr. |
36 | 36 | ||
37 | eventfd = os.dup(sys.stdout.fileno()) | 37 | eventfd = os.dup(sys.stdout.fileno()) |
38 | bb.event.worker_pipe = os.fdopen(eventfd, 'w', 0) | 38 | bb.event.worker_pipe = os.fdopen(eventfd, 'w', 0) |
39 | # Replace those fds with our own | 39 | |
40 | # map stdout to stderr | ||
40 | os.dup2(sys.stderr.fileno(), sys.stdout.fileno()) | 41 | os.dup2(sys.stderr.fileno(), sys.stdout.fileno()) |
41 | 42 | ||
43 | # Replace those fds with our own | ||
44 | #logout = data.expand("${TMPDIR}/log/stdout.%s" % os.getpid(), self.cfgData, True) | ||
45 | #mkdirhier(os.path.dirname(logout)) | ||
46 | #newso = open("/tmp/stdout.%s" % os.getpid(), 'w') | ||
47 | #os.dup2(newso.fileno(), sys.stdout.fileno()) | ||
48 | #os.dup2(newso.fileno(), sys.stderr.fileno()) | ||
49 | |||
42 | # Save out the PID so that the event can include it the | 50 | # Save out the PID so that the event can include it the |
43 | # events | 51 | # events |
44 | bb.event.worker_pid = os.getpid() | 52 | bb.event.worker_pid = os.getpid() |
45 | bb.event.usestdout = False | 53 | bb.event.useStdout = False |
46 | |||
47 | 54 | ||
48 | import bb.cooker | 55 | import bb.cooker |
49 | 56 | ||
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 77af92abee..f49b2836b6 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -152,6 +152,9 @@ def exec_func(func, d, dirs = None): | |||
152 | os.dup2(so.fileno(), oso[1]) | 152 | os.dup2(so.fileno(), oso[1]) |
153 | os.dup2(se.fileno(), ose[1]) | 153 | os.dup2(se.fileno(), ose[1]) |
154 | 154 | ||
155 | # Since we've remapped stdout and stderr, its safe for log messages to be printed there now | ||
156 | # exec_func can nest so we have to save state | ||
157 | origstdout = bb.event.useStdout | ||
155 | bb.event.useStdout = True | 158 | bb.event.useStdout = True |
156 | 159 | ||
157 | locks = [] | 160 | locks = [] |
@@ -179,7 +182,10 @@ def exec_func(func, d, dirs = None): | |||
179 | for lock in locks: | 182 | for lock in locks: |
180 | bb.utils.unlockfile(lock) | 183 | bb.utils.unlockfile(lock) |
181 | 184 | ||
182 | bb.event.useStdout = False | 185 | sys.stdout.flush() |
186 | sys.stderr.flush() | ||
187 | |||
188 | bb.event.useStdout = origstdout | ||
183 | 189 | ||
184 | # Restore the backup fds | 190 | # Restore the backup fds |
185 | os.dup2(osi[0], osi[1]) | 191 | os.dup2(osi[0], osi[1]) |
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index f5ba6eab3c..45458c2d63 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -110,6 +110,7 @@ def fire_from_worker(event, d): | |||
110 | if not event.startswith("<event>") or not event.endswith("</event>"): | 110 | if not event.startswith("<event>") or not event.endswith("</event>"): |
111 | print("Error, not an event %s" % event) | 111 | print("Error, not an event %s" % event) |
112 | return | 112 | return |
113 | #print "Got event %s" % event | ||
113 | event = pickle.loads(event[7:-8]) | 114 | event = pickle.loads(event[7:-8]) |
114 | fire_ui_handlers(event, d) | 115 | fire_ui_handlers(event, d) |
115 | 116 | ||
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py index 5bb30e8dd3..21692d930d 100644 --- a/bitbake/lib/bb/msg.py +++ b/bitbake/lib/bb/msg.py | |||
@@ -133,7 +133,9 @@ def error(msgdomain, msg, fn = None): | |||
133 | 133 | ||
134 | def fatal(msgdomain, msg, fn = None): | 134 | def fatal(msgdomain, msg, fn = None): |
135 | bb.event.fire(MsgFatal(msg), None) | 135 | bb.event.fire(MsgFatal(msg), None) |
136 | print('FATAL: %s' % (msg)) | 136 | |
137 | if bb.event.useStdout: | ||
138 | print('FATAL: %s' % (msg)) | ||
137 | sys.exit(1) | 139 | sys.exit(1) |
138 | 140 | ||
139 | def plain(msg, fn = None): | 141 | def plain(msg, fn = None): |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 67f265bc80..ef5256f14c 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -1467,5 +1467,5 @@ class runQueuePipe(): | |||
1467 | while self.read(): | 1467 | while self.read(): |
1468 | continue | 1468 | continue |
1469 | if len(self.queue) > 0: | 1469 | if len(self.queue) > 0: |
1470 | print("Warning, worker left partial message") | 1470 | print("Warning, worker left partial message: %s" % self.queue) |
1471 | self.fd.close() | 1471 | self.fd.close() |