JsMacros-JEP

JsMacros-JEP

1k Downloads

Can't use module multiprocessing

FYWinds opened this issue ยท 1 comments

commented

Problem

When running a script with main logic put in multiprocessing, the file will be normally loaded and run till the end, with no errors in chat.
The only problem is that, the main logic in Process(targer=main) seems never being runned, and in the console of the Game, there will be an error seems to be from starting a new jvm.

Unrecognized option: -c
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

This could be a upstream problem of JEP, but I didn't find any similar error in JEP's repo.

How to reproduce

I'm currently trying to use multiprocessing to create a Subprocess, and thus work with Events to stop the script at any time. Here's my code.

def main():
    while True:
        print(1)

p = multiprocessing.Process(target=main)
p.start()

def kill(*args)
    print(0)
    p.terminate()
    Chat.log("XXX Stopped")

JsMacros.once("TerminateScript", JavaWrapper.methodToJava(kill))
p.join()

Environment

Windows 11 Pro 22H2 Build 22621.1555
JEP build on python 3.10.9 with MSVC v143
Java(TM) SE Runtime Environment (build 1.8.0_371-b11)
Minecraft 1.12.2 with forge forge:1.12.2-14.23.5.2860
JsMacros JsMacros/JsMacros@f0130f7

Minecraft launch script

Only key points that I modified from normal launch script.

set PYTHONHOME=C:\ProgramData\miniconda3
set PATH=%PYTHONHOME%;%PYTHONHOME%\Scripts;%PATH%

"C:\\Program Files\\Java\\jre-1.8\\bin\\java.exe" -Xmx8192m^
      -Djava.library.path=D:\Games\JSMacros\.minecraft\versions\1.12.2\natives-windows-x86_64;C:\ProgramData\miniconda3^
commented

Upstream lack of support found: ninia/jep#30 (comment)
Closing the issue.