Skip to content

Commit b5c3d7a

Browse files
authored
Python SDK: remove blocking argument of flush (#11314)
1 parent ecd74e4 commit b5c3d7a

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
title: Migration Guides
33
order: 1000
4-
redirect: reference/migration/migration-0-25
4+
redirect: reference/migration/migration-0-26
55
---
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Migrating from 0.25 to 0.26
3+
order: 984
4+
---
5+
<!-- ^^^ this number must be _decremented_ when you copy/paste this file -->
6+
7+
## Python SDK: removed `blocking` argument for `flush`
8+
Use the new `timeout_sec` argument instead.
9+
For non-blocking, use `timeout_sec=0`.
10+
Mostly you can just call `.flush()` with no arguments.
11+
That will block until all writes either finishes or an error occurs (e.g. the gRPC connection is severed).

rerun_py/rerun_bindings/rerun_bindings.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,7 @@ def disconnect(recording: PyRecordingStream | None = None) -> None:
10831083
Subsequent log messages will be buffered and either sent on the next call to `connect_grpc` or `spawn`.
10841084
"""
10851085

1086-
# TODO(#11294): remove `blocking` argument and put the `*` first
1087-
def flush(blocking: bool = True, recording: PyRecordingStream | None = None, *, timeout_sec: float = 1e38) -> None:
1086+
def flush(*, timeout_sec: float = 1e38, recording: PyRecordingStream | None = None) -> None:
10881087
"""Block until outstanding data has been flushed to the sink."""
10891088

10901089
#

rerun_py/rerun_sdk/rerun/recording_stream.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,22 +471,19 @@ def __exit__(
471471
def to_native(self) -> bindings.PyRecordingStream:
472472
return self.inner
473473

474-
# TODO(#11294): remove `blocking` argument
475-
def flush(self, blocking: bool = True, *, timeout_sec: float = 1e38) -> None:
474+
def flush(self, *, timeout_sec: float = 1e38) -> None:
476475
"""
477476
Initiates a flush the batching pipeline and optionally waits for it to propagate to the underlying file descriptor (if any).
478477
479478
Parameters
480479
----------
481-
blocking:
482-
If true, the flush will block until the flush is complete.
483480
timeout_sec:
484481
Wait at most this many seconds.
485482
If the timeout is reached, an error is raised.
486483
If set to zero, the flush will be started but not waited for.
487484
488485
"""
489-
bindings.flush(blocking=blocking, recording=self.to_native(), timeout_sec=timeout_sec)
486+
bindings.flush(timeout_sec=timeout_sec, recording=self.to_native())
490487

491488
def __del__(self) -> None: # type: ignore[no-untyped-def]
492489
recording = self.to_native()

rerun_py/src/python_bridge.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,22 +1613,16 @@ fn disconnect(py: Python<'_>, recording: Option<&PyRecordingStream>) {
16131613
}
16141614

16151615
/// Block until outstanding data has been flushed to the sink.
1616-
// TODO(#11294): remove `blocking` argument and put the `*` first
16171616
#[pyfunction]
1618-
#[pyo3(signature = (blocking = true, recording = None, *, timeout_sec = 1e38))] // Can't use infinity here because of python_check_signatures.py
1619-
fn flush(
1620-
py: Python<'_>,
1621-
blocking: bool,
1622-
recording: Option<&PyRecordingStream>,
1623-
timeout_sec: f32,
1624-
) -> PyResult<()> {
1617+
#[pyo3(signature = (*, timeout_sec = 1e38, recording = None))] // Can't use infinity here because of python_check_signatures.py
1618+
fn flush(py: Python<'_>, timeout_sec: f32, recording: Option<&PyRecordingStream>) -> PyResult<()> {
16251619
let Some(recording) = get_data_recording(recording) else {
16261620
return Ok(());
16271621
};
16281622

16291623
// Release the GIL in case any flushing behavior needs to cleanup a python object.
16301624
py.allow_threads(|| -> PyResult<()> {
1631-
if !blocking || timeout_sec == 0.0 {
1625+
if timeout_sec == 0.0 {
16321626
recording
16331627
.flush_async()
16341628
.map_err(|err: SinkFlushError| PyRuntimeError::new_err(err.to_string()))?;

0 commit comments

Comments
 (0)