How to use the execnet.gateway_base.Message function in execnet

To help you get started, we’ve selected a few execnet 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 pytest-dev / execnet / execnet / gateway_base.py View on Github external
def status(message, gateway):
        # we use the channelid to send back information
        # but don't instantiate a channel object
        d = {
            "numchannels": len(gateway._channelfactory._channels),
            "numexecuting": gateway._execpool.active_count(),
            "execmodel": gateway.execmodel.backend,
        }
        gateway._send(Message.CHANNEL_DATA, message.channelid, dumps_internal(d))
        gateway._send(Message.CHANNEL_CLOSE, message.channelid)
github pytest-dev / execnet / execnet / gateway_base.py View on Github external
def from_io(io):
        try:
            header = io.read(9)  # type 1, channel 4, payload 4
            if not header:
                raise EOFError("empty read")
        except EOFError:
            e = sys.exc_info()[1]
            raise EOFError("couldnt load message header, " + e.args[0])
        msgtype, channel, payload = struct.unpack("!bii", header)
        return Message(msgtype, channel, io.read(payload))
github pytest-dev / execnet / execnet / gateway_base.py View on Github external
target = gateway._channelfactory.new(message.channelid)
        target._strconfig = loads_internal(message.data, gateway)

    types = [
        status,
        reconfigure,
        gateway_terminate,
        channel_exec,
        channel_data,
        channel_close,
        channel_close_error,
        channel_last_message,
    ]
    for i, handler in enumerate(types):
        Message._types.append(handler)
        setattr(Message, handler.__name__.upper(), i)
github pytest-dev / execnet / execnet / gateway_base.py View on Github external
def _send(self, msgcode, channelid=0, data=bytes()):
        message = Message(msgcode, channelid, data)
        try:
            message.to_io(self._io)
            self._trace("sent", message)
        except (IOError, ValueError):
            e = sys.exc_info()[1]
            self._trace("failed to send", message, e)
            # ValueError might be because the IO is already closed
            raise IOError("cannot send (already closed?)")
github pytest-dev / execnet / testing / test_basics.py View on Github external
def test_wire_protocol(self):
        for i, handler in enumerate(Message._types):
            one = py.io.BytesIO()
            data = "23".encode("ascii")
            Message(i, 42, data).to_io(one)
            two = py.io.BytesIO(one.getvalue())
            msg = Message.from_io(two)
            assert msg.msgcode == i
            assert isinstance(msg, Message)
            assert msg.channelid == 42
            assert msg.data == data
            assert isinstance(repr(msg), str)
github pytest-dev / execnet / execnet / gateway_base.py View on Github external
else:
            target = gateway._channelfactory.new(message.channelid)
        target._strconfig = loads_internal(message.data, gateway)

    types = [
        status,
        reconfigure,
        gateway_terminate,
        channel_exec,
        channel_data,
        channel_close,
        channel_close_error,
        channel_last_message,
    ]
    for i, handler in enumerate(types):
        Message._types.append(handler)
        setattr(Message, handler.__name__.upper(), i)