8000 fix without exception · QuantEcon/lecture-python-intro@011f97c · GitHub
[go: up one dir, main page]

Skip to content

Commit 011f97c

Browse files
committed
fix without exception
1 parent f981a5f commit 011f97c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

testing/install_pyodide_libs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ async def main():
7171

7272

7373
if __name__ == '__main__':
74-
try:
75-
# Check if running inside an existing event loop
76-
loop = asyncio.get_running_loop()
77-
asyncio.ensure_future(main())
78-
except RuntimeError:
79-
# No running event loop, safe to use asyncio.run()
74+
if asyncio.get_event_loop().is_running():
75+
# If an event loop is already running, use create_task()
76+
task = asyncio.create_task(main())
77+
asyncio.get_event_loop().run_until_complete(task)
78+
else:
79+
# If no event loop is running, use asyncio.run()
8080
asyncio.run(main())

0 commit comments

Comments
 (0)
0