_try_read: hacky fix to make GNU make less angry.
We'll have to stop using nonblocking reads, unfortunately. But this seems to work better than nothing. There's still a race condition that could theoretically make GNU make angry, unfortunately, since we briefly set the socket to nonblocking.
This commit is contained in:
parent
9d5afd67f0
commit
662f53896a
1 changed files with 12 additions and 6 deletions
8
jwack.py
8
jwack.py
|
|
@ -32,14 +32,20 @@ def _release(n):
|
|||
|
||||
|
||||
def _try_read(fd, n):
|
||||
# FIXME: this isn't actually safe, because GNU make can't handle it if
|
||||
# the socket is nonblocking. Ugh. That means we'll have to do their
|
||||
# horrible SIGCHLD hack after all.
|
||||
fcntl.fcntl(_fds[0], fcntl.F_SETFL, os.O_NONBLOCK)
|
||||
try:
|
||||
b = os.read(_fds[0], 1) # FIXME try: block
|
||||
try:
|
||||
b = os.read(_fds[0], 1)
|
||||
except OSError, e:
|
||||
if e.errno == errno.EAGAIN:
|
||||
return ''
|
||||
else:
|
||||
raise
|
||||
finally:
|
||||
fcntl.fcntl(_fds[0], fcntl.F_SETFL, 0)
|
||||
return b and b or None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue