Skip to content

Commit c6bf140

Browse files
committed
feat(pmjs): Add event loop to pmjs
1 parent 3e4ce63 commit c6bf140

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/pythonmonkey/cli/pmjs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import sys, os, signal, getopt
77
import readline
8+
import asyncio
89
import pythonmonkey as pm
910
from pythonmonkey.lib import pmdb
1011

@@ -356,8 +357,11 @@ def main():
356357
assert False, "unhandled option"
357358

358359
if (len(args) > 0):
359-
globalInitModule.patchGlobalRequire()
360-
pm.runProgramModule(args[0], args, requirePath)
360+
async def runJS():
361+
globalInitModule.patchGlobalRequire()
362+
pm.runProgramModule(args[0], args, requirePath)
363+
await pm.wait() # blocks until all asynchronous calls finish
364+
asyncio.run(runJS())
361365
elif (enterRepl or forceRepl):
362366
globalInitModule.initReplLibs()
363367
repl()

0 commit comments

Comments
 (0)