Example #1
0
 def cleanup(self):
     if not self._closed:
         self._closed = True
         # Release the drain. They should have released us as well.
         self._drain = None
         # Stop reading.
         ruv.readStop(self.stream)
         # And, finally, close and reap the stream.
         # print "active" if ruv.isActive(self.stream) else "inactive"
         # print "closing" if ruv.isClosing(self.stream) else "not closing"
         if not ruv.isClosing(self.stream):
             ruv.closeAndFree(self.stream)
Example #2
0
def readStreamCB(stream, status, buf):
    status = intmask(status)
    # We only restash in the success case, not the error cases.
    vat, source = ruv.unstashStream(stream)
    assert isinstance(source, StreamSource), "Implementation error"
    # Don't read any more. We'll call .readStart() when we're interested in
    # reading again.
    ruv.readStop(stream)
    with scopedVat(vat):
        if status > 0:
            # Restash required.
            ruv.stashStream(stream, (vat, source))
            data = charpsize2str(buf.c_base, status)
            source.deliver(data)
        elif status == -4095:
            # EOF.
            source.complete()
        else:
            msg = ruv.formatError(status).decode("utf-8")
            source.abort(u"libuv error: %s" % msg)
Example #3
0
def readStreamCB(stream, status, buf):
    status = intmask(status)
    # We only restash in the success case, not the error cases.
    vat, source = ruv.unstashStream(stream)
    assert isinstance(source, StreamSource), "Implementation error"
    # Don't read any more. We'll call .readStart() when we're interested in
    # reading again.
    ruv.readStop(stream)
    with scopedVat(vat):
        if status > 0:
            # Restash required.
            ruv.stashStream(stream, (vat, source))
            data = charpsize2str(buf.c_base, status)
            source.deliver(data)
        elif status == -4095:
            # EOF.
            source.complete()
        else:
            msg = ruv.formatError(status).decode("utf-8")
            source.abort(u"libuv error: %s" % msg)
Example #4
0
 def pause(self):
     # uv_read_stop() is idempotent.
     ruv.readStop(self.stream)
     self._reading = False
     self.pauses += 1
     return StreamUnpauser(self)