Esempio n. 1
0
        def __init__(
            self,
            flux_handle,
            topic,
            payload=None,
            nodeid=flux.constants.FLUX_NODEID_ANY,
            flags=0,
        ):
            # hold a reference for destructor ordering
            self._handle = flux_handle
            dest = raw.flux_future_destroy
            super(RPC.InnerWrapper, self).__init__(
                ffi,
                lib,
                handle=None,
                match=ffi.typeof(lib.flux_rpc).result,
                prefixes=["flux_rpc_"],
                destructor=dest,
            )
            if isinstance(flux_handle, Wrapper):
                flux_handle = flux_handle.handle

            topic = encode_topic(topic)
            payload = encode_payload(payload)

            self.handle = raw.flux_rpc(flux_handle, topic, payload, nodeid,
                                       flags)
Esempio n. 2
0
        def __init__(
            self,
            flux_handle,
            topic,
            payload=None,
            nodeid=flux.constants.FLUX_NODEID_ANY,
            flags=0,
        ):
            # hold a reference for destructor ordering
            self._handle = flux_handle
            dest = raw.flux_future_destroy
            super(RPC.InnerWrapper, self).__init__(
                ffi,
                lib,
                handle=None,
                match=ffi.typeof(lib.flux_rpc).result,
                prefixes=["flux_rpc_"],
                destructor=dest,
            )
            if isinstance(flux_handle, Wrapper):
                flux_handle = flux_handle.handle

            topic = encode_topic(topic)
            payload = encode_payload(payload)

            self.handle = raw.flux_rpc(flux_handle, topic, payload, nodeid, flags)
Esempio n. 3
0
        def __init__(self,
                     flux_handle,
                     topic,
                     payload=None,
                     rankset="all",
                     flags=0):
            # hold a reference for destructor ordering
            self._handle = flux_handle
            dest = raw.flux_mrpc_destroy
            super(MRPC.InnerWrapper, self).__init__(
                ffi,
                lib,
                handle=None,
                match=ffi.typeof(lib.flux_mrpc).result,
                prefixes=["flux_mrpc_"],
                destructor=dest,
            )

            # pylint: disable=duplicate-code
            if isinstance(flux_handle, Wrapper):
                flux_handle = flux_handle.handle

            topic = encode_topic(topic)
            payload = encode_payload(payload)
            rankset = encode_rankset(rankset)

            self.handle = raw.flux_mrpc(flux_handle, topic, payload, rankset,
                                        flags)
Esempio n. 4
0
    def respond(self, message, payload=None):
        """Respond to a flux rpc

        :param message: The message to respond to
        :type message: Message
        :param payload: The (optional) payload to include in the response
        :type payload: None, str, bytes, unicode, or json-serializable
        """
        if isinstance(message, Message):
            message = message.handle
        payload = encode_payload(payload)
        return self.flux_respond(message, payload)
Esempio n. 5
0
    def __init__(
        self,
        flux_handle,
        topic,
        payload=None,
        nodeid=flux.constants.FLUX_NODEID_ANY,
        flags=0,
    ):
        if isinstance(flux_handle, Wrapper):
            # keep the flux_handle alive for the lifetime of the RPC
            self.flux_handle = flux_handle
            flux_handle = flux_handle.handle

        topic = encode_topic(topic)
        payload = encode_payload(payload)

        future_handle = raw.flux_rpc(flux_handle, topic, payload, nodeid, flags)
        super(RPC, self).__init__(future_handle, prefixes=["flux_rpc_", "flux_future_"])
Esempio n. 6
0
    def __init__(
        self,
        flux_handle,
        topic,
        payload=None,
        nodeid=flux.constants.FLUX_NODEID_ANY,
        flags=0,
    ):
        if isinstance(flux_handle, Wrapper):
            # keep the flux_handle alive for the lifetime of the RPC
            self.flux_handle = flux_handle
            flux_handle = flux_handle.handle

        topic = encode_topic(topic)
        payload = encode_payload(payload)

        future_handle = raw.flux_rpc(flux_handle, topic, payload, nodeid,
                                     flags)
        super(RPC, self).__init__(future_handle,
                                  prefixes=["flux_rpc_", "flux_future_"])
Esempio n. 7
0
        def __init__(self, flux_handle, topic, payload=None, rankset="all", flags=0):
            # hold a reference for destructor ordering
            self._handle = flux_handle
            dest = raw.flux_mrpc_destroy
            super(MRPC.InnerWrapper, self).__init__(
                ffi,
                lib,
                handle=None,
                match=ffi.typeof(lib.flux_mrpc).result,
                prefixes=["flux_mrpc_"],
                destructor=dest,
            )

            # pylint: disable=duplicate-code
            if isinstance(flux_handle, Wrapper):
                flux_handle = flux_handle.handle

            topic = encode_topic(topic)
            payload = encode_payload(payload)
            rankset = encode_rankset(rankset)

            self.handle = raw.flux_mrpc(flux_handle, topic, payload, rankset, flags)
Esempio n. 8
0
 def payload(self, value):
     self.payload_str = encode_payload(value)
Esempio n. 9
0
 def from_event_encode(cls, topic, payload=None):
     payload = encode_payload(payload)
     handle = raw.flux_event_encode(topic, payload)
     return cls(handle=handle)
Esempio n. 10
0
 def from_event_encode(cls, topic, payload=None):
     payload = encode_payload(payload)
     handle = raw.flux_event_encode(topic, payload)
     return cls(handle=handle)
Esempio n. 11
0
 def payload(self, value):
     self.payload_str = encode_payload(value)