Skip to content

Commit b18a9b7

Browse files
zsolfacebook-github-bot
authored andcommitted
monarch_env: use main_function for -allocator target (#32)
Summary: Pull Request resolved: #32 This is the second try after D74718068 got backed out. Turns out `bootstrap_main` from `_rust_bindings` needs a reference to a running event loop, so it can't simply be passed into `asyncio.run()`: https://github.com/awestlake87/pyo3-asyncio#a-note-about-asynciorun We wrap it into a trivial coroutine instead. Reviewed By: amirafzali Differential Revision: D75284480 fbshipit-source-id: 24352a212d0490d2f1fe4eb6245212c1abfc1bfa
1 parent f46d0b5 commit b18a9b7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

python/monarch/bootstrap_main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616

1717
async def main():
18+
from monarch._rust_bindings.monarch_hyperactor.bootstrap import bootstrap_main
19+
1820
await bootstrap_main()
1921

2022

21-
def invoke_main() -> None:
23+
def invoke_main():
2224
# if this is invoked with the stdout piped somewhere, then print
2325
# changes its buffering behavior. So we default to the standard
2426
# behavior of std out as if it were a terminal.
2527
sys.stdout.reconfigure(line_buffering=True)
26-
global bootstrap_main
2728
# TODO: figure out what from worker_main.py we should reproduce here.
28-
from monarch._rust_bindings.monarch_hyperactor.bootstrap import bootstrap_main
2929

3030
with (
3131
importlib.resources.path("monarch", "py-spy") as pyspy,
@@ -39,5 +39,4 @@ def invoke_main() -> None:
3939

4040

4141
if __name__ == "__main__":
42-
# Do not add code here, it won't be run. Add them to the function called below.
4342
invoke_main() # pragma: no cover

0 commit comments

Comments
 (0)