<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_all(fd, s, deadline=None):
 """Arrange for all of bytestring `s` to be written to the file descriptor `fd`. :param int fd: File descriptor to write to. :param bytes s: Bytestring to write to file descriptor. :param float deadline: If not :data:`None`, absolute UNIX timestamp after which timeout should occur. :raises mitogen.core.TimeoutError: Bytestring could not be written entirely before deadline was exceeded. :raises mitogen.parent.EofError: Stream indicated EOF, suggesting the child process has exitted. :raises mitogen.core.StreamError: File descriptor was disconnected before write could complete. """

    timeout = None
    written = 0
    poller = PREFERRED_POLLER()
    poller.start_transmit(fd)

    try:
        while written < len(s):
            if deadline is not None:
                timeout = max(0, deadline - time.time())
            if timeout == 0:
                raise mitogen.core.TimeoutError('write timed out')

            if mitogen.core.PY3:
                window = memoryview(s)[written:]
            else:
                window = buffer(s, written)

            for fd in poller.poll(timeout):
                n, disconnected = mitogen.core.io_op(os.write, fd, window)
                if disconnected:
                    raise EofError('EOF on stream during write')

                written += n
    finally:
        poller.close()