summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-08-03 06:48:58 +0000
committerZac Medico <zmedico@gentoo.org>2007-08-03 06:48:58 +0000
commita3f9506f2f577a08a122b20953af66f39e91716f (patch)
tree8fcbbbf7f6787d8af086316fbb048ee5b961adca /pym
parentb24966c9fc12f959355a82329cec6c340c158b70 (diff)
downloadportage-a3f9506f2f577a08a122b20953af66f39e91716f.tar.gz
portage-a3f9506f2f577a08a122b20953af66f39e91716f.tar.bz2
portage-a3f9506f2f577a08a122b20953af66f39e91716f.zip
In portage.spawn() logging, put the read end of the pipe in O_NONBLOCK mode just once at the beginning. This avoids unnecessary fcntl calls and removes one more opportunity to trigger EAGAIN errors on FreeBSD.
svn path=/main/trunk/; revision=7548
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index c5f05e0fb..4d9f05e56 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2465,32 +2465,28 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
fd_flags[f] = fcntl.fcntl(f.fileno(), fcntl.F_GETFL)
buffsize = 65536
eof = False
+ # Use non-blocking mode to prevent read
+ # calls from blocking indefinitely.
+ try:
+ fcntl.fcntl(master_file.fileno(), fcntl.F_SETFL,
+ fd_flags[master_file] | os.O_NONBLOCK)
+ except EnvironmentError, e:
+ if e.errno != errno.EAGAIN:
+ raise
+ del e
+ # The EAGAIN error signals eof on FreeBSD.
+ eof = True
while not eof:
events = select.select(iwtd, owtd, ewtd)
for f in events[0]:
- # Use non-blocking mode to prevent read
- # calls from blocking indefinitely.
- try:
- fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
- fd_flags[f] | os.O_NONBLOCK)
- except EnvironmentError, e:
- if e.errno != errno.EAGAIN:
- raise
- del e
- # The EAGAIN error signals eof on FreeBSD.
- eof = True
- break
buf = array.array('B')
try:
buf.fromfile(f, buffsize)
except EOFError:
pass
- fcntl.fcntl(f.fileno(), fcntl.F_SETFL, fd_flags[f])
if not buf:
eof = True
break
- # Use blocking mode for writes since we'd rather block than
- # trigger a EWOULDBLOCK error.
if f is master_file:
buf.tofile(stdout_file)
stdout_file.flush()