Skip to content

Commit 0a15813

Browse files
dulinrileyfacebook-github-bot
authored andcommitted
Move import out of ProcMesh.__del__ (#472)
Summary: Pull Request resolved: #472 You cannot import a module during the Python runtime shutdown, which leads to an error if any ProcMesh objects are being garbage collected without being stopped. Move this import to the top level, it's not important to import it lazily. Reviewed By: zdevito, colin2328 Differential Revision: D77973599 fbshipit-source-id: 0f90785b3b1f53efc0a5b0f5664cc7d42d295071
1 parent 27dab00 commit 0a15813

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

python/monarch/_src/actor/proc_mesh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import os
1010
import sys
11+
import warnings
1112
from contextlib import AbstractContextManager
1213

1314
from typing import (
@@ -275,8 +276,6 @@ async def __aexit__(
275276
# Finalizer to check if the proc mesh was closed properly.
276277
def __del__(self) -> None:
277278
if not self._stopped:
278-
import warnings
279-
280279
warnings.warn(
281280
f"unstopped ProcMesh {self!r}",
282281
ResourceWarning,

0 commit comments

Comments
 (0)