diff --git a/econtext/core.py b/econtext/core.py index 0e21481e..ae43383c 100644 --- a/econtext/core.py +++ b/econtext/core.py @@ -89,16 +89,6 @@ def set_cloexec(fd): fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC) -def write_all(fd, s): - written = 0 - while written < len(s): - rc = os.write(fd, buffer(s, written)) - if not rc: - raise IOError('short write') - written += rc - return written - - class Channel(object): def __init__(self, context, handle): self._context = context diff --git a/econtext/master.py b/econtext/master.py index df613862..de2d0055 100644 --- a/econtext/master.py +++ b/econtext/master.py @@ -70,6 +70,16 @@ def create_child(*args): return pid, os.dup(parentfp.fileno()) +def write_all(fd, s): + written = 0 + while written < len(s): + rc = os.write(fd, buffer(s, written)) + if not rc: + raise IOError('short write') + written += rc + return written + + def read_with_deadline(fd, size, deadline): timeout = deadline - time.time() if timeout > 0: @@ -299,7 +309,7 @@ class Stream(econtext.core.Stream): def _ec0_received(self): LOG.debug('%r._ec0_received()', self) - econtext.core.write_all(self.transmit_side.fd, self.get_preamble()) + write_all(self.transmit_side.fd, self.get_preamble()) discard_until(self.receive_side.fd, 'EC1\n', time.time() + 10.0) def _connect_bootstrap(self):