コード例 #1
0
    def write(self, data, offset=None):
        if offset is None:
            offset = self.offset
        off = 0
        with self.lock:
            offs = self.offset
            if offset is not None:
                offs = offset
            if len(data) == 0:
                resp = self._dorpc(fcall.Twrite(offset=offs, data=data))
            while off < len(data):
                n = min(len(data), self.iounit)

                resp = self._dorpc(
                    fcall.Twrite(offset=offs, data=data[off:off + n]))
                off += resp.count
                offs += resp.count
                if resp.count < n:
                    break
            if offset is None:
                self.offset = offs
        return off
コード例 #2
0
        def next(resp=None, exc=None, tb=None):
            if resp:
                ctxt['off'] += resp.count
                ctxt['offset'] += resp.count
            if ctxt['off'] < len(data) or not (exc or resp):
                n = min(len(data), self.iounit)

                self._dorpc(
                    fcall.Twrite(offset=ctxt['offset'],
                                 data=data[ctxt['off']:ctxt['off'] + n]), next,
                    fail or callback)
            else:
                if offset is None:
                    self.offset = ctxt['offset']
                self.respond(callback, ctxt['off'], exc, tb)