osbrain icon indicating copy to clipboard operation
osbrain copied to clipboard

setting the serialization for loopback and in-process sockets

Open bangxiangyong opened this issue 4 years ago • 1 comments

in the run function of agent, the serializer for sockets has been hardcoded to be 'pickle', shouldn't this be set to the serializer of the individual agents, or the global serializer in osbrain.config?

what i find is that 'pickle' was still used to serialize the parameters of passed functions, although i specifically set to use other serializers.

therefore, changing the global osbrain.config['SERIALIZER'] doesn't change this behaviour either

snippet in agent.py

    @Pyro4.oneway
    def run(self):
        """
        Start the main loop.
        """
        # A loopback socket where, for example, timers are processed
        self.bind(
            'REP',
            alias='loopback',
            addr='loopback',
            handler=self._handle_loopback,
            transport='inproc',
            serializer='pickle',
        )

        # This in-process socket handles safe access to
        # memory from other threads (i.e. when using Pyro proxies).
        self.bind(
            'REP',
            alias='_loopback_safe',
            addr='_loopback_safe',
            handler=self._handle_loopback_safe,
            transport='inproc',
            serializer='pickle',
        )

i believe the fix should be to set serializer=self._serializer instead of serializer='pickle'

bangxiangyong avatar Sep 04 '20 13:09 bangxiangyong

Thanks for reporting this issue! :blush:

It sounds reasonable. Do you have a reproducible case that fails due to forcing pickle serialization in each of those cases? It would be great to have those in order to add tests when we make the required changes.

Pull requests are welcome, but always with the corresponding tests. :wink:

Peque avatar Sep 04 '20 14:09 Peque