Skip to content

sim2bot.CameraStream.close

close() -> None

Unsubscribe this camera and make the operation idempotently closed.

Returns:

  • None

    Calling the method again after closure has no effect.

Source code in sim2bot/client.py
def close(self) -> None:
    """Unsubscribe this camera and make the operation idempotently closed.

    Returns:
        Calling the method again after closure has no effect.
    """
    if self._closed:
        return
    self._closed = True
    self._robot._remove_camera(self.camera_id)

Practical examples

Examples use objects discovered from the current scene rather than hard-coded robot metadata.

Close manually

feed = sim.camera(camera_id)
frame = feed.read()
feed.close()

Prefer automatic cleanup

with sim.camera(camera_id) as feed:
    frame = feed.read()

Guidance

Usage tip

Closing unused streams stops the browser from rendering and encoding those camera views.


See also