Skip to content

Commit 06e651f

Browse files
shayne-fletchermeta-codesync[bot]
authored andcommitted
v1/logging: avoid spinning up ... more tests (#1725)
Summary: Pull Request resolved: #1725 this diff adds end-to-end tests for `LoggingMeshClient::spawn,` `set_mode`, and `flush`, covering both values of `MESH_ENABLE_LOG_FORWARDING`. with forwarding disabled we assert that `spawn()` returns a client with `forwarder_mesh == None`, that `set_mode()` refuses to enable streaming (and rejects `aggregate_window_sec` unless streaming is true), and that `flush()` returns `Ok(())` as a no-op. with forwarding enabled we assert that `forwarder_mesh.is_some()`, that `set_mode()` can enable streaming and set an aggregate window, and that `flush()` runs the sync flush barrier and returns `Ok(())`. the diff also adds `await_unit()` to `AwaitPyExt` so tests can await `PyPythonTask`s that conceptually return `None`, and tightens the rust-side docs for `LoggingMeshClient`, its `drop` semantics, and the `flush` protocol. Reviewed By: pzhan9 Differential Revision: D85969320 fbshipit-source-id: b0dfcbb712d60853a97b6e8e7a03e075cc7fbda1
1 parent d9a07c4 commit 06e651f

File tree

2 files changed

+347
-17
lines changed

2 files changed

+347
-17
lines changed

monarch_hyperactor/src/pytokio.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ pub(crate) fn ensure_python() {
572572
// - turn that into `Py<T>`.
573573
pub(crate) trait AwaitPyExt {
574574
async fn await_py<T: PyClass>(self) -> Result<Py<T>, PyErr>;
575+
576+
// For tasks whose future just resolves to (), i.e. no object,
577+
// just "did it work?"
578+
async fn await_unit(self) -> Result<(), PyErr>;
575579
}
576580

577581
#[cfg(test)]
@@ -597,4 +601,20 @@ impl AwaitPyExt for PyPythonTask {
597601
Ok(obj)
598602
})
599603
}
604+
605+
async fn await_unit(mut self) -> Result<(), PyErr> {
606+
let fut = self
607+
.take_task()
608+
.expect("PyPythonTask already consumed in await_unit");
609+
610+
// Await it. This still gives us a Py<PyAny> because
611+
// Python-side return values are always materialized as 'some
612+
// object'. For "no value" / None, that's just a PyAny(None).
613+
let py_any: Py<PyAny> = fut.await?;
614+
615+
// We don't need to extract anything. Just drop it.
616+
drop(py_any);
617+
618+
Ok(())
619+
}
600620
}

0 commit comments

Comments
 (0)