Skip to content

Setting sync_request_timeout when remote calls a local function. #573

@jchan-legendpower

Description

@jchan-legendpower

I have the following setup where I patch certain modules on my remote server to use local modules:

        self.logger.info("Connecting to RPyC server on Pi")
        conn = rpyc.classic.connect(
            self._connector.addr
        )
        conn._config["sync_request_timeout"] = 600
        conn.root.getconn()._config["sync_request_timeout"] = 600
        # This is needed so that the host can serve requests to run code from the Pi
        _ = rpyc.BgServingThread(conn)

        self.logger.info("Uploading legend_test module")
        rpyc.classic.upload_module(conn, legend_test)

        # Some modules must always be run on the host even when called from the Pi
        self.logger.info("Patching modules")
        conn.modules.sys.modules[
            "legend_test.log_utils.logger_manager"
        ] = legend_test.log_utils.logger_manager
        conn.modules.sys.modules[
            "legend_test.utils.data_recorder"
        ] = legend_test.utils.data_recorder
        conn.modules.sys.modules["legend_test.utils.timer"] = legend_test.utils.timer

This works as expected like described in https://rpyc.readthedocs.io/en/latest/tutorial/tut4.html

However, I've that when my remote calls a function to be run locally, the request timeout still seems to be 30 seconds despite what I've set above. I still get:

2025-03-24 20:29:26,890 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG - Mar 25 03:29:30 DEBUG SLAVE/18812[RpycSpawnThread-builtins.method-1995415928-1948026760]: Exception caught
2025-03-24 20:29:26,892 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG - Traceback (most recent call last):
2025-03-24 20:29:26,894 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/protocol.py", line 369, in _dispatch_request
2025-03-24 20:29:26,896 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     res = self._HANDLERS[handler](self, *args)
2025-03-24 20:29:26,898 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,899 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/protocol.py", line 863, in _handle_call
2025-03-24 20:29:26,901 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     return obj(*args, **dict(kwargs))
2025-03-24 20:29:26,903 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,905 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/legend_test/drivers/gen3modem.py", line 95, in call
2025-03-24 20:29:26,908 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     return func(self, *args, **kwargs)
2025-03-24 20:29:26,910 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,912 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/legend_test/drivers/gen3modem.py", line 274, in update_firmware
2025-03-24 20:29:26,914 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     show_timer(
2025-03-24 20:29:26,916 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/netref.py", line 239, in __call__
2025-03-24 20:29:26,918 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
2025-03-24 20:29:26,921 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,923 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/netref.py", line 63, in syncreq
2025-03-24 20:29:26,925 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     return conn.sync_request(handler, proxy, *args)
2025-03-24 20:29:26,927 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,929 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/protocol.py", line 744, in sync_request
2025-03-24 20:29:26,931 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     return _async_res.value
2025-03-24 20:29:26,933 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -            ^^^^^^^^^^^^^^^^
2025-03-24 20:29:26,935 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/async_.py", line 109, in value
2025-03-24 20:29:26,937 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     self.wait()
2025-03-24 20:29:26,939 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -   File "/tmp/temp_rpyc_10618/python/lib/python3.12/site-packages/rpyc/core/async_.py", line 55, in wait
2025-03-24 20:29:26,941 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG -     raise AsyncResultTimeout("result expired")
2025-03-24 20:29:26,943 - legend_sequencer.SshConnector.pi@10.0.0.1.device - DEBUG - TimeoutError: result expired

I'm not sure how to force this timeout to be longer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions