Skip to content

Question: how does the runtime prevent netref'ed values from being garbage collected? #511

Description

@sidneycadot

Hello,

Suppose I have the following server:

import rpyc

class MyService(rpyc.Service):
    def exposed_func(self):
        return {"a": 10, "b": 20}

service = MyService()
server = rpyc.utils.server.ThreadedServer(service, port=20000)
server.start()

When a client queries func(), it receives a netref to the dictionary that is supposed to exist at the server side.

However, at the server side, the dict value has already gone out of scope after exposed_func() returns, and is thus eligible for being garbage collected.

How does the server-side ensure that the value returned by exposed_func() still exists for the netref to be valid? Who takes ownership (and manages the lifetime of) the dict returned by the exposed_func()?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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