spawn a python executable and suspend until complete

spawn a python executable and suspend until complete

Anonymous
Not applicable
1,212 Views
4 Replies
Message 1 of 5

spawn a python executable and suspend until complete

Anonymous
Not applicable

Hi.

I would like to be able to spawn a python script from lisp and suspend lisp until the python script completes.

A good candidate seemed to be acet-sys-spawn,

but the following attempts did nothing and returned an exit code of -1.

(acet-sys-spawn 1 "c:\\tom\\tmp\\tmp5\\primitivelinesAndIndices.py")

(acet-sys-spawn 1 "C:\\Python27\\python.exe c:\\tom\\tmp\\tmp5\\primitivelinesAndIndices.py")

The invocation (acet-sys-spawn 1 "C:\\Program Files\\windows nt\\accessories\\wordpad.exe")

did start wordpad, waited until it was closed, then returned an error code of 0 as expected.

Also,

(command "shell" "C:\\Python27\\ArcGIS10.5\\python.exe c:\\tom\\tmp\\tmp5\\primitivelinesAndIndices.py")

will run the python script, but execution doesn't suspend, so lisp would have to poll for a state change somehow before retrieving the python scripts output, and that is a lot clunkier than what I want.

Any ideas or suggestions?

0 Likes
Accepted solutions (1)
1,213 Views
4 Replies
Replies (4)
Message 2 of 5

CodeDing
Advisor
Advisor
Accepted solution

@Anonymous ,

 

Have you tried..?

(acet-sys-spawn 1 "C:\\Python27\\python.exe" "c:\\tom\\tmp\\tmp5\\primitivelinesAndIndices.py")

notice my 2 parentheses, this ensures that the .exe is the command and the .py is the argument.

 

Best,

~DD 

0 Likes
Message 3 of 5

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

put it in batch and call the batch from shell

 

hope it work

moshe

 

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks!

That for suggesting setting both the executable and its file argument in their own sets of quotation marks. works exactly as I hoped.

0 Likes
Message 5 of 5

Anonymous
Not applicable

That does function, but, while the console suspends, autocad keeps running. I will certainly keep this in mind when that behavior is wanted, which is equally likely. Thanks!

0 Likes