如何使用Python中的子过程两次运行相同的EXE文件
我是使用API的新手。我需要同时两次运行相同的EXE文件,并使用API调用与每个呼叫进行通信。当我只想仅运行一次EXE文件时,我按照以下步骤与它进行通信
import subprocess
import requests
command = "App.exe --restserver"
subprocess.Popen(command)
server_address = "127.0.0.1:5000"
end_point = "/load/"
parameters = {
"type" = "designI"
}
url = "http://" + server_address + end_point
response_load_designI = requests.post(f"{url}", parameters)
,现在我想再次运行app.exe,但是加载 “ designii”
我仍然有 “ designi”
启动和运行。我想知道第二次运行app.exe的服务器地址是什么?有没有办法强迫第二次运行使用其他地址?我在两个终端尝试分别运行它们,但是在两个终端中,我都得到了相同的服务器地址('127.0.0.1:5000'
)。
I am new to using APIs. I need to run the same exe file twice at the same time and use API calls to communicate with each one. When I want to run the exe file just once, I follow these steps to communicate with it
import subprocess
import requests
command = "App.exe --restserver"
subprocess.Popen(command)
server_address = "127.0.0.1:5000"
end_point = "/load/"
parameters = {
"type" = "designI"
}
url = "http://" + server_address + end_point
response_load_designI = requests.post(f"{url}", parameters)
Now I want to run App.exe again but load "designII"
this time while I still have "designI"
up and running. I am wondering what will be the server address for the 2nd time I run App.exe? Is there a way to force the 2nd run to use a different address? I tried in two terminals to run them separately but in both terminals I got the same server address ('127.0.0.1:5000'
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论