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


                if payload is None or payload == ffi.NULL:
                    payload = ffi.NULL
                elif not isinstance(payload, basestring):
                    payload = json.dumps(payload)

                if isinstance(nodeid, basestring):
                    # String version is multiple nodeids
                    self.handle = lib.flux_rpc_multi(
                        flux_handle, topic, payload, nodeid, flags)
                else:
                    self.handle = lib.flux_rpc(
                        flux_handle, topic, payload, nodeid, flags)
Beispiel #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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
0
 def __init__(self,
              type_id=flux.FLUX_MSGTYPE_REQUEST,
              handle=None,
              destruct=False,):
     super(self.__class__, self).__init__(
         ffi, lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=[
             'flux_msg_',
             'FLUX_MSG',
         ],
         destructor=raw.flux_msg_destroy if destruct else None,)
     if handle is None:
         self.handle = raw.flux_msg_create(type_id)
Beispiel #6
0
        def __init__(
            self,
            handle=None,
            match=ffi.typeof("flux_future_t *"),
            filter_match=True,
            prefixes=None,
            destructor=raw.flux_future_destroy,
        ):
            # avoid using a static list as a default argument
            # pylint error 'dangerous-default-value'
            if prefixes is None:
                prefixes = ["flux_rpc_", "flux_future_"]

            super().__init__(ffi, lib, handle, match, filter_match, prefixes,
                             destructor)
Beispiel #7
0
 def __init__(self,
              type_id=flux.constants.FLUX_MSGTYPE_REQUEST,
              handle=None,
              destruct=False,):
     super(self.__class__, self).__init__(
         ffi, lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=[
             'flux_msg_',
             'FLUX_MSG',
         ],
         destructor=raw.flux_msg_destroy if destruct else None,)
     if handle is None:
         self.handle = raw.flux_msg_create(type_id)
Beispiel #8
0
        def __init__(
            self,
            handle=None,
            match=ffi.typeof("flux_future_t *"),
            filter_match=True,
            prefixes=None,
            destructor=raw.flux_future_destroy,
        ):
            # avoid using a static list as a default argument
            # pylint error 'dangerous-default-value'
            if prefixes is None:
                prefixes = ["flux_future_"]

            super(Future.InnerWrapper, self).__init__(
                ffi, lib, handle, match, filter_match, prefixes, destructor
            )
Beispiel #9
0
 def __init__(
     self,
     type_id=flux.constants.FLUX_MSGTYPE_REQUEST,
     handle=None,
     destruct=False,
 ):
     super(Message.InnerWrapper, self).__init__(
         ffi,
         lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=["flux_msg_", "FLUX_MSG"],
         destructor=raw.flux_msg_destroy if destruct else None,
     )
     self.destruct = destruct
     if handle is None:
         self.handle = raw.flux_msg_create(type_id)
Beispiel #10
0
 def __init__(
     self,
     type_id=flux.constants.FLUX_MSGTYPE_REQUEST,
     handle=None,
     destruct=False,
 ):
     super(Message.InnerWrapper, self).__init__(
         ffi,
         lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=["flux_msg_", "FLUX_MSG"],
         destructor=raw.flux_msg_destroy if destruct else None,
     )
     self.destruct = destruct
     if handle is None:
         self.handle = raw.flux_msg_create(type_id)
Beispiel #11
0
 def __init__(self,
              type_id=flux.FLUX_MSGTYPE_REQUEST,
              handle=None,
              destruct=False):
     self.destruct = destruct
     if handle is None:
         self.external = False
         handle = raw.flux_msg_create(type_id)
     else:
         self.external = True
     super(self.__class__, self).__init__(
         ffi, lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=[
             'flux_msg_',
             'FLUX_MSG',
         ], )
Beispiel #12
0
 def __init__(
     self,
     type_id=flux.constants.FLUX_MSGTYPE_REQUEST,
     handle=None,
 ):
     super(Message.InnerWrapper, self).__init__(
         ffi,
         lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=["flux_msg_", "FLUX_MSG"],
         destructor=raw.flux_msg_destroy,
     )
     if handle is None:
         self.handle = raw.flux_msg_create(type_id)
     else:
         #  Always take a reference on externally supplied flux_msg_t
         #   so that it can't be destroyed while the Python
         #   Message object is still active.
         raw.flux_msg_incref(self.handle)
Beispiel #13
0
 def __init__(self,
              type_id=flux.FLUX_MSGTYPE_REQUEST,
              handle=None,
              destruct=False):
     self.destruct = destruct
     if handle is None:
         self.external = False
         handle = raw.flux_msg_create(type_id)
     else:
         self.external = True
     super(self.__class__, self).__init__(
         ffi,
         lib,
         handle=handle,
         match=ffi.typeof(lib.flux_msg_create).result,
         prefixes=[
             'flux_msg_',
             'FLUX_MSG',
         ],
     )
Beispiel #14
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)
Beispiel #15
0
        def __init__(
            self,
            handle=None,
            match=ffi.typeof("flux_future_t *"),
            filter_match=True,
            prefixes=None,
            destructor=raw.flux_future_destroy,
        ):
            # avoid using a static list as a default argument
            # pylint error 'dangerous-default-value'
            if prefixes is None:
                prefixes = ["flux_future_"]

            # enable Future(fut_obj) to work by just re-wrapping the
            # underlying future object and increments its reference to avoid
            # pre-mature destruction when the original obj gets GC'd
            if isinstance(handle, Future):
                handle.incref()
                handle = handle.handle

            super(Future.InnerWrapper,
                  self).__init__(ffi, lib, handle, match, filter_match,
                                 prefixes, destructor)
Beispiel #16
0
        def __init__(self,
                     flux_handle,
                     topic,
                     payload=None,
                     nodeid=flux.constants.FLUX_NODEID_ANY,
                     flags=0,
                     handle=None):
            # hold a reference for destructor ordering
            self._handle = flux_handle
            dest = raw.flux_future_destroy
            super(self.__class__, self).__init__(
                ffi,
                lib,
                handle=handle,
                match=ffi.typeof(lib.flux_rpc).result,
                prefixes=[
                    'flux_rpc_',
                ],
                destructor=dest,
            )
            if handle is None:
                if isinstance(flux_handle, Wrapper):
                    flux_handle = flux_handle.handle

                if payload is None or payload == ffi.NULL:
                    payload = ffi.NULL
                elif not isinstance(payload, basestring):
                    payload = json.dumps(payload)

                if isinstance(nodeid, basestring):
                    # String version is multiple nodeids
                    self.handle = lib.flux_rpc_multi(flux_handle, topic,
                                                     payload, nodeid, flags)
                else:
                    self.handle = lib.flux_rpc(flux_handle, topic, payload,
                                               nodeid, flags)