Example #1
0
def connectCB(connect, status):
    status = intmask(status)
    stream = connect.c_handle

    try:
        vat, resolvers = ruv.unstashStream(stream)
        fountResolver, drainResolver = unwrapList(resolvers)
        assert isinstance(fountResolver, LocalResolver)
        assert isinstance(drainResolver, LocalResolver)

        with scopedVat(vat):
            if status >= 0:
                debug_print("Made connection!")
                fountResolver.resolve(StreamFount(stream, vat))
                drainResolver.resolve(StreamDrain(stream, vat))
            else:
                error = "Connection failed: " + ruv.formatError(status)
                debug_print(error)
                fountResolver.smash(StrObject(error.decode("utf-8")))
                drainResolver.smash(StrObject(error.decode("utf-8")))
                # Done with stream.
                ruv.closeAndFree(stream)
    except:
        if not we_are_translated():
            raise
Example #2
0
def connectStreamCB(connect, status):
    status = intmask(status)
    stream = connect.c_handle

    try:
        vat, resolvers = ruv.unstashStream(stream)
        sourceResolver, sinkResolver = unwrapList(resolvers)
        assert isinstance(sourceResolver, LocalResolver)
        assert isinstance(sinkResolver, LocalResolver)

        with scopedVat(vat):
            if status >= 0:
                debug_print("Made connection!")
                wrappedStream = ruv.wrapStream(stream, 2)
                sourceResolver.resolve(StreamSource(wrappedStream, vat))
                sinkResolver.resolve(StreamSink(wrappedStream, vat))
            else:
                error = "Connection failed: " + ruv.formatError(status)
                debug_print(error)
                sourceResolver.smash(StrObject(error.decode("utf-8")))
                sinkResolver.smash(StrObject(error.decode("utf-8")))
                # Done with stream.
                ruv.closeAndFree(stream)
    except:
        if not we_are_translated():
            raise
Example #3
0
 def cleanup(self):
     if not self._closed:
         self._closed = True
         # 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 #4
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)