Python 在处理子进程时,我的程序是CPU绑定还是IO绑定?
使用Python,我试图弄清楚我应该使用Python 在处理子进程时,我的程序是CPU绑定还是IO绑定?,python,multithreading,console,python-asyncio,python-multithreading,Python,Multithreading,Console,Python Asyncio,Python Multithreading,使用Python,我试图弄清楚我应该使用多处理、线程还是异步IO,第一步是弄清楚我的程序是CPU绑定还是IO绑定 代码中最慢的部分是与异步编程之前创建的子进程交互。有关守则如下: # First curl command to existing JS console running on my machine curl_command = <curl command here> cmd = shlex.split(curl_command) subpr
多处理
、线程
还是异步IO
,第一步是弄清楚我的程序是CPU绑定还是IO绑定
代码中最慢的部分是与异步编程之前创建的子进程交互。有关守则如下:
# First curl command to existing JS console running on my machine
curl_command = <curl command here>
cmd = shlex.split(curl_command)
subprocess.Popen(cmd, stderr=subprocess.DEVNULL)
# Different curl command
self.other_command = self._other_curl_command()
# Interact with an existing JS console running on my machine
output_one = call_one()
output_two = call_two()
output_three = call_three()
#将第一个curl命令发送到在我的机器上运行的现有JS控制台
curl_命令=
cmd=shlex.split(curl\u命令)
subprocess.Popen(cmd,stderr=subprocess.DEVNULL)
#不同的curl命令
self.other\u command=self.\u other\u curl\u command()
#与我的机器上运行的现有JS控制台交互
output_one=call_one()
output_two=调用_two()
输出三=调用三()
需要注意的是,这些调用是对我在机器上运行的JS控制台的调用。这些是I/O绑定的活动吗?如果是这样,我是否应该使用
线程
/异步
?很难说这段代码是做什么的。subprocess.Popen()
的返回值不保留在变量中。调用_one()
和其他函数做什么?很难说这段代码做什么。subprocess.Popen()
的返回值不保留在变量中。调用_one()
和其他函数做什么?