Skip to content

Commit 2d952f9

Browse files
zdevitofacebook-github-bot
authored andcommitted
stop becomes a future (#833)
Summary: Pull Request resolved: #833 Now it works with synchronous uses as well. ghstack-source-id: 302569853 exported-using-ghexport Reviewed By: highker, mariusae Differential Revision: D80017456 fbshipit-source-id: 8ab207c4fffdf5d58b59ce81c271e3947d40bc5c
1 parent 173f2e8 commit 2d952f9

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:
@@ -1183,8 +1182,8 @@ def _new_with_shape(self, shape: Shape) -> "ActorMesh[T]":
11831182
def __repr__(self) -> str:
11841183
return f"ActorMesh(class={self._class}, shape={self._shape}), inner={type(self._inner)})"
11851184

1186-
async def stop(self):
1187-
await self._inner.stop()
1185+
def stop(self) -> "Future[None]":
1186+
return Future(coro=self._inner.stop())
11881187

11891188
@property
11901189
def initialized(self) -> Future[None]:

0 commit comments

Comments
 (0)