|
13 | 13 | # --- Sinks --- |
14 | 14 |
|
15 | 15 |
|
| 16 | +def is_recording_enabled(recording: RecordingStream | None) -> bool: |
| 17 | + if recording is not None: |
| 18 | + return bindings.is_enabled(recording.inner) # type: ignore[no-any-return] |
| 19 | + return bindings.is_enabled() # type: ignore[no-any-return] |
| 20 | + |
| 21 | + |
16 | 22 | def connect( |
17 | 23 | addr: str | None = None, |
18 | 24 | *, |
@@ -47,7 +53,7 @@ def connect( |
47 | 53 |
|
48 | 54 | """ |
49 | 55 |
|
50 | | - if not bindings.is_enabled(): |
| 56 | + if not is_recording_enabled(recording): |
51 | 57 | logging.warning("Rerun is disabled - connect() call ignored") |
52 | 58 | return |
53 | 59 |
|
@@ -102,7 +108,7 @@ def save( |
102 | 108 |
|
103 | 109 | """ |
104 | 110 |
|
105 | | - if not bindings.is_enabled(): |
| 111 | + if not is_recording_enabled(recording): |
106 | 112 | logging.warning("Rerun is disabled - save() call ignored. You must call rerun.init before saving a recording.") |
107 | 113 | return |
108 | 114 |
|
@@ -149,7 +155,7 @@ def stdout(default_blueprint: BlueprintLike | None = None, recording: RecordingS |
149 | 155 |
|
150 | 156 | """ |
151 | 157 |
|
152 | | - if not bindings.is_enabled(): |
| 158 | + if not is_recording_enabled(recording): |
153 | 159 | logging.warning("Rerun is disabled - save() call ignored. You must call rerun.init before saving a recording.") |
154 | 160 | return |
155 | 161 |
|
@@ -234,7 +240,7 @@ def serve( |
234 | 240 |
|
235 | 241 | """ |
236 | 242 |
|
237 | | - if not bindings.is_enabled(): |
| 243 | + if not is_recording_enabled(recording): |
238 | 244 | logging.warning("Rerun is disabled - serve() call ignored") |
239 | 245 | return |
240 | 246 |
|
@@ -346,7 +352,7 @@ def spawn( |
346 | 352 |
|
347 | 353 | """ |
348 | 354 |
|
349 | | - if not bindings.is_enabled(): |
| 355 | + if not is_recording_enabled(recording): |
350 | 356 | logging.warning("Rerun is disabled - spawn() call ignored.") |
351 | 357 | return |
352 | 358 |
|
|
0 commit comments