runqueue.py: Use fcntl to make the worker pipes non-blocking
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
fd42ffa273
commit
5c62833766
|
@ -26,6 +26,7 @@ from bb import msg, data, event, mkdirhier, utils
|
||||||
import bb, os, sys
|
import bb, os, sys
|
||||||
import signal
|
import signal
|
||||||
import stat
|
import stat
|
||||||
|
import fcntl
|
||||||
|
|
||||||
class TaskFailure(Exception):
|
class TaskFailure(Exception):
|
||||||
"""Exception raised when a task in a runqueue fails"""
|
"""Exception raised when a task in a runqueue fails"""
|
||||||
|
@ -1161,12 +1162,16 @@ class runQueuePipe():
|
||||||
def __init__(self, pipein, pipeout, d):
|
def __init__(self, pipein, pipeout, d):
|
||||||
self.fd = pipein
|
self.fd = pipein
|
||||||
os.close(pipeout)
|
os.close(pipeout)
|
||||||
|
fcntl.fcntl(self.fd, fcntl.F_SETFL, fcntl.fcntl(self.fd, fcntl.F_GETFL) | os.O_NONBLOCK)
|
||||||
self.queue = ""
|
self.queue = ""
|
||||||
self.d = d
|
self.d = d
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
start = len(self.queue)
|
start = len(self.queue)
|
||||||
self.queue = self.queue + os.read(self.fd, 1024)
|
try:
|
||||||
|
self.queue = self.queue + os.read(self.fd, 1024)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
end = len(self.queue)
|
end = len(self.queue)
|
||||||
index = self.queue.find("</event>")
|
index = self.queue.find("</event>")
|
||||||
while index != -1:
|
while index != -1:
|
||||||
|
|
Loading…
Reference in New Issue