How to use the riffle.cumin.marshall function in Riffle

To help you get started, we’ve selected a few Riffle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exis-io / Exis / python / pyRiffle / riffle / crust.py View on Github external
# TODO: Differentiate Riffle errors vs. other exceptions,
                    # maybe reraise other exceptions.
                    if canReturn:
                        domain.YieldError(resultID, "wamp.error.runtime_error", json.dumps([str(error)]))
                    else:
                        print "An exception occured: ", error
                else:
                    if canReturn:
                        if ret is None:
                            ret = []
                        elif isinstance(ret, tuple):
                            ret = list(ret)
                        else:
                            ret = [ret]

                        domain.Yield(resultID, cumin.marshall(ret))

            # Control messages. These should really just be deferreds, but not implemented yet
            if i in self.control:
                d = greenlet(self.control[i]).switch(*args)

                # If user code called .wait(), this deferred is emitted, waiting on the results of some operation
                if d is not None:
                    self.deferreds[d.cb], self.deferreds[d.eb] = d, d
github exis-io / Exis / python / pyRiffle / riffle / crust.py View on Github external
def _invoke(self, endpoint, args, coreFunction, doesReturn):
        '''
        Publish or Call. Invokes targetFunction for the given endpoint and handler.

        :param coreFunction: the intended core function, either Subscribe or Register
        :param doesReturn: True if this handler can receive results (is a call)
        '''

        d = Deferred()
        d.canReturn = doesReturn
        d.mantleDomain = self.mantleDomain
        self.app.deferreds[d.cb], self.app.deferreds[d.eb] = d, d

        coreFunction(endpoint, d.cb, d.eb, cumin.marshall(args))
        return d