Skip to content

.serve_grpc() should be possible to use independently of recording stream #12313

@jleibs

Description

@jleibs

In the Python SDK, the only way to spawn an internal grpc_server is using the .serve_grpc() APIs.

The grpc server is stored in a LogSink and is automatically cleaned up if the corresponding recording goes out of scope or is disconnected.

This leads to confusing situations like the following:

import rerun as rr

rr.init("rerun_example_grpc_server")

# Create a grpc server
uri = rr.serve_grpc()

# A user might want to connect to it with a dedicated stream
rec1 = rr.RecordingStream("rerun_example_grpc_server")
rec1.connect_grpc(uri)
rec1.log("object_stream", rr.TextLog("This works"))

# Later they set up the global recording to go to file isntead
rr.save("rerun_example_grpc_server.rerun")

# Doing the same thing, now fail because the grpc server was implicitly shut down
# when the global recording was switched to a file sin
rec2 = rr.RecordingStream("rerun_example_grpc_server")
rec2.connect_grpc(uri)
rec2.log("object_stream", rr.TextLog("This fail"))

It would be nice if a dedicated server object was created, separate of the stream concepts:

import rerun as rr

# Create a grpc server. As long as the server object exists
server = rr.GrpcServer()

# A user can then connect to the server with a stream
rec1 = rr.RecordingStream("rerun_example_grpc_server")
rec1.connect_grpc(server)
rec1.log("object_stream", rr.TextLog("This works"))

# Changes to the global stream have no implicit impact on the server object
rr.save("rerun_example_grpc_server.rerun")

# A user can still connect and log to the server
rec2 = rr.RecordingStream("rerun_example_grpc_server")
rec2.connect_grpc(server)
rec2.log("object_stream", rr.TextLog("This still works"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions