2

I want to spawn a Java process from python script. And then read the stderr stream of the java process from the calling python script. Can this be done using pipes?

I try to spawn the java process from python script using python's win32 api's. I create the java process having the write end of pipe by using the win32process.CreateProcess() method.

Then I wait on the java process to signal (i.e. finish) using win32event.WaitForSingleObject(). Then I try to read through the read end of pipe from the python script using win32file.ReadFile() method.

But I have no idea how to let the java program to communicate with the python script. Do i need to use signal handler's in the java code? Kindly give an example...

Thank you, Parag

1 Answer 1

3

You should use subprocess.Popen for this, and then call .communicate() to send input, wait for finish, and then get stderr back.

The win32 APIs are both overkill and needless complexity for what you're trying to do.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Amber,But wont I need to take special care at the java side for this IPC...? I mean wont i need to use signal handler's there...?
+1, although I think the Win32 APIs are needlessly complex for basically anything one can do compared to the alternatives ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.