Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using Wolfram WebEngine Py for generating documents #13

Open
s4m13337 opened this issue Dec 10, 2024 · 0 comments
Open

Issue when using Wolfram WebEngine Py for generating documents #13

s4m13337 opened this issue Dec 10, 2024 · 0 comments

Comments

@s4m13337
Copy link

PS: I'm posting this on behalf of Jörg Schönau at Additive GmbH

We observed an issune when using WEPy for generating documents.
It should be easy to reproduce following this steps:

  1. Create an initialization code file with the following content and
    name it myinit.m:
ReportFunction[x_]:=Module[
     {nbobj, res},
     Print["myinit.m | ReportFunction | function started"];
     Print["x: "Head[x], "  x: ", InputForm[x]];
     UsingFrontEnd[
         Print["myinit.m | ReportFunction | after UsingFrontEnd", x];
         nbobj = GenerateDocument["ExampleData/BasicTemplate.nb", x];
         Print["myinit.m | ReportFunction | nbobj created: ", nbobj];
         res = ExportString[nbobj, "HTML"];
         Print["myinit.m | ReportFunction | res created: ", 
StringLength[res]];
         NotebookClose[nbobj];
         Print["myinit.m | ReportFunction | nbobj closed."];
         Return[res]
     ]
]
  1. Change the content of testapp/form/index.wl to:
FormFunction["author" -> "String", ReportFunction]
  1. Now launch the WEPy like this:
py -3.11 -m wolframwebengine testapp --initfile myinit.m
  1. Finally call that page in a browser http://localhost:18000/form

Now you can put any string into that form and [ubmit
That page will run forever and the log file of WEPy says:

Kernel writes commands to socket: <Socket: uri=tcp://127.0.0.1:50973>
Kernel receives evaluated expressions from socket: <Socket: 
uri=tcp://127.0.0.1:50974>
Initializing Kernel logger on socket tcp://127.0.0.1:50977
Kernel process started with PID: 8
Connected to logging socket: tcp://127.0.0.1:50977
Kernel 8 is ready. Startup took 4.61 seconds.
GET /form done in 0.8590s: 200
192.168.98.200 - Administrator [26/Mar/2024:10:38:04 +0100] "myinit.m | 
ReportFunction | function started" 1 8
"x: "*Association   x:  InputForm[<|"author" -> "Otto Meier"|>]
192.168.98.200 - Administrator [26/Mar/2024:10:38:06 +0100] "myinit.m | 
ReportFunction | after UsingFrontEnd <|author -> Otto Meier|>" 1 8

So the evaluation stops after the Mathematica.exe has successfully
launched.
The GenerateDocument command never evaluates...
WolframKernel.exe and Mathematica.exe stay in the list of processes
but will not get stopped when stopping the WEPy script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant