Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 同时收集数据并列出清单_Python_Asynchronous_Multiprocessing_Python Requests - Fatal编程技术网

Python 同时收集数据并列出清单

Python 同时收集数据并列出清单,python,asynchronous,multiprocessing,python-requests,Python,Asynchronous,Multiprocessing,Python Requests,我的烧瓶应用程序工作正常。它检查心脏监护仪的健康状态(由具有ID的医生监督),并收集医生当前的活动。下面我展示了我编写的部分代码(在ubuntu中使用python)。然而,我想要的是: 我们收到用户在Web浏览器中填写的ID(医生的ID) 然后并行执行2项活动:我们收集健康评分,第二项活动可以并行进行,因为我们已经知道医生的ID:我们可以立即自动检查医生的活动 我列了一个清单,把这些分数合并在一起 如何使代码并行?这两台服务器彼此独立。因为现在我要等到我拿到壁炉监护仪,然后医生才知道它的活动

我的烧瓶应用程序工作正常。它检查心脏监护仪的健康状态(由具有ID的医生监督),并收集医生当前的活动。下面我展示了我编写的部分代码(在ubuntu中使用python)。然而,我想要的是:

  • 我们收到用户在Web浏览器中填写的ID(医生的ID)
  • 然后并行执行2项活动:我们收集健康评分,第二项活动可以并行进行,因为我们已经知道医生的ID:我们可以立即自动检查医生的活动
  • 我列了一个清单,把这些分数合并在一起
如何使代码并行?这两台服务器彼此独立。因为现在我要等到我拿到壁炉监护仪,然后医生才知道它的活动。在请求之前我做一些搜索操作,在请求之后我做一些繁重的计算,因此我正在寻找一种并行编程/CPU密集型解决方案

@app.route('/getstatus',methods=['POST','GET'])
def get_score():
    if request.method=='POST':
    #we wait till the web user has filled in the ID of the doctor
        id = request.form['id']

        #hearthmonitor Processor 1 parallelactivity 1 before the request I am searching the servername of the hearthmonitor that belongs with the ID
        urlhearth=serverhearth+id
        rh= requests.get(serverhearth, allow_redirects=False)
        h1=rh.content


        #doctormonitor Processor 2 parallelactivity 2 before the request I am searching the servername of the doctorserver (department server) that belongs with the ID. This is what I want to run in parrallel with activity 1   
        urldoc=server+id
        rd= requests.get(urldoc, allow_redirects=False)
        d1= rd.content



        #we make a list of their outcomes together
        list=[doctor, hearth]

您似乎正在使用Python请求库。与该库进行异步请求的一些项目在its中链接。这不仅仅与请求有关。例如,在医生提出要求后,我们计算过去两个小时他在电脑中输入的字数,然后计算平均值。请求只是一小部分,您似乎正在使用Python请求库。与该库进行异步请求的一些项目在its中链接。这不仅仅与请求有关。例如,在医生提出要求后,我们计算过去两个小时他在电脑中输入的字数,然后计算平均值。请求只是一小部分。