Esempio n. 1
0
    def run(self, data):
        if self.closed:
            raise userError(u"run/1: Couldn't write to closed file")

        with ruv.scopedBufs([data]) as bufs:
            ruv.fsWrite(self._vat.uv_loop, self._fs, self._fd, bufs, 1, -1,
                        writeFileCB)
Esempio n. 2
0
    def run(self, data):
        if self.closed:
            raise userError(u"run/1: Couldn't send to closed stream")

        # XXX backpressure?
        uv_write = ruv.alloc_write()
        with ruv.scopedBufs([data]) as bufs:
            ruv.write(uv_write, self._stream._stream, bufs, 1, writeStreamCB)
Esempio n. 3
0
    def run(self, data):
        if self.closed:
            raise userError(u"run/1: Couldn't write to closged file")

        sb = ruv.scopedBufs([data], self)
        bufs = sb.allocate()
        fs = ruv.alloc_fs()
        ruv.stashFS(fs, (self._vat, sb))
        ruv.fsWrite(self._vat.uv_loop, fs, self._fd, bufs, 1, -1, writeFileCB)
Esempio n. 4
0
    def run(self, data):
        if self.closed:
            raise userError(u"run/1: Couldn't send to closed stream")

        # XXX backpressure?
        uv_write = ruv.alloc_write()
        sb = ruv.scopedBufs([data], self)
        bufs = sb.allocate()
        ruv.stashWrite(uv_write, (self._vat, sb))
        ruv.write(uv_write, self._stream._stream, bufs, 1, writeStreamCB)
Esempio n. 5
0
    def recv(self, atom, args):
        if atom is FLOWINGFROM_1:
            return self

        if atom is RECEIVE_1:
            if self._closed:
                raise userError(u"Can't send data to a closed stream!")

            if args[0] is NullObject:
                # Pump-style notification that we're supposed to close.
                self.flush()
                self.cleanup()
                return NullObject

            # XXX we are punting completely on any notion of backpressure for
            # now. How to fix:
            # * Figure out how to get libuv to signal that a write is likely
            #   to complete

            data = unwrapBytes(args[0])
            uv_write = ruv.alloc_write()
            with ruv.scopedBufs([data]) as bufs:
                ruv.write(uv_write, self.stream, bufs, 1, writeCB)

            return NullObject

        if atom is FLOWABORTED_1:
            self.cleanup()
            return NullObject

        if atom is FLOWSTOPPED_1:
            # XXX flush() is currently a no-op, but that's not right for the
            # case where there's pending data.
            self.flush()
            self.cleanup()
            return NullObject

        if atom is FLUSH_0:
            self.flush()
            return NullObject

        raise Refused(self, atom, args)
Esempio n. 6
0
File: files.py Progetto: dckc/typhon
 def queueWrite(self):
     with ruv.scopedBufs([self.data]) as bufs:
         ruv.fsWrite(self.vat.uv_loop, self.fs, self.fd, bufs,
                     1, -1, writeSetContentsCB)
Esempio n. 7
0
File: files.py Progetto: dckc/typhon
 def queueWrite(self):
     with ruv.scopedBufs(self.bufs) as bufs:
         ruv.fsWrite(self.vat.uv_loop, self.fs, self.fd, bufs,
                     len(self.bufs), -1, writeCB)
Esempio n. 8
0
 def queueWrite(self):
     with ruv.scopedBufs([self.data]) as bufs:
         ruv.fsWrite(self.vat.uv_loop, self.fs, self.fd, bufs, 1, self.pos,
                     writeSetContentsCB)
Esempio n. 9
0
 def queueWrite(self):
     with ruv.scopedBufs(self.bufs) as bufs:
         ruv.fsWrite(self.vat.uv_loop, self.fs, self.fd, bufs,
                     len(self.bufs), self.pos, writeCB)