Skip to content

Commit 67c170a

Browse files
committed
stop becomes a future
Now it works with synchronous uses as well. Differential Revision: [D80017456](https://our.internmc.facebook.com/intern/diff/D80017456/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80017456/)! ghstack-source-id: 302569853 Pull Request resolved: #833
1 parent 7b16dd0 commit 67c170a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

monarch_hyperactor/src/actor_mesh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ impl PythonActorMesh {
238238
Err(self.pickling_err())
239239
}
240240

241-
fn stop<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
241+
fn stop<'py>(&self) -> PyResult<PyPythonTask> {
242242
let actor_mesh = self.inner.clone();
243-
crate::runtime::future_into_py(py, async move {
243+
PyPythonTask::new(async move {
244244
let actor_mesh = actor_mesh
245245
.take()
246246
.await

python/monarch/_src/actor/actor_mesh.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@ async def task():
506506
return PythonTask.from_coroutine(task()).spawn()
507507

508508
async def stop(self) -> None:
509-
inner = await Future(coro=self._inner.task())
510-
await inner.stop()
509+
await (await self._inner).stop()
511510

512511
@staticmethod
513512
def _restore(inner: ActorMeshProtocol) -> ActorMeshProtocol:
@@ -1186,8 +1185,8 @@ def _new_with_shape(self, shape: Shape) -> "ActorMesh[T]":
11861185
def __repr__(self) -> str:
11871186
return f"ActorMesh(class={self._class}, shape={self._shape}), inner={type(self._inner)})"
11881187

1189-
async def stop(self):
1190-
await self._inner.stop()
1188+
def stop(self) -> "Future[None]":
1189+
return Future(coro=self._inner.stop())
11911190

11921191
@property
11931192
def initialized(self) -> Future[None]:

0 commit comments

Comments
 (0)