1

First of all I am a beginner.So pardon me if I am asking a dumb question.

I am trying to write a python automation code. With this code I should be able to run multiple programs like servers(mock backend api servers, C++ programs and java programs).

So what I thought is to make executables of C++ and JAVA programs and start them using python.

As the start what I did was, downloaded the wiremock- standalone and tried to start the wiremock server with python.

Here I have tried following two at different times.

os.system("java -jar <wiremock_name>")
print(5)

subprocess.call("java -jar <wiremock_name>", shell=true)
print(5)

At both times, the server was successfully deployed.But the print statement was not executed. I tried couple of threading scripts too. But same thing happened.

But it is the requirement(start the server, then configure it using some curl commands).

for me it looks like python is not coming back after it start the server. When we use the terminal we have to use the ctrl+C to manually end the process. I here server should also run.

So what is happening here?

What should I do/follow to implement this functionality?

  • 2
    The documentation for `subprocess.call` is clear: "Run the command described by args. Wait for command to complete" and `os.system` similarly has you wait. You need to use a method that actually runs the process in the background, like `Popen`. – Grismar Nov 01 '21 at 10:33
  • This doesn't solve your question but you can also shut down the WireMock server by sending a POST request to `/__admin/shutdown/`. API details here: http://wiremock.org/docs/api/#tag/System/paths/~1__admin~1shutdown/post . Might be useful once you get your problem resolved. – agoff Nov 01 '21 at 13:47
  • 1
    Thank you all, @Grismar I studied bit about it and tried it.It worked. And also what agoff says is also true. It is hard to find and kill the server. – Janith Priyankara Nov 01 '21 at 14:55

0 Answers0