代码:
import requests
import pandas as pd
import concurrent.futures
with open("load_test_data.json") as f:
request_data = json.load(f)
response_details = {}
response_details['content'] = []
response_details['status_code'] = []
response_details['time'] = []
counter = 0
def hit_the_url(request_content):
url = "http://xxxxxx"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = request_content)
counter += 1
print(f"{counter} number of requests performed")
response_details['content'].append(response.content)
print(response.status_code)
response_details['status_code'].append(response.status_code)
print(response.elapsed.total_seconds())
response_details['time'].append(response.elapsed.total_seconds() * 1000)
return 'Success'
with concurrent.futures.ProcessPoolExecutor() as executor:
results = [executor.submit(hit_the_url, i) for i in request_data ]
for f in concurrent.futures.as_completed(results):
print(f.result())
df = pd.DataFrame(response_details)
df.to_csv("response_details.csv")
我在这里犯了什么错误?该代码未打印任何内容。它也没有停止停止。 Kinda处于悬挂状态。
PS,第一次尝试使用多处理模块。请帮忙。谢谢
简短回答
否
Long Answer
当您运行docker build
时,当前目录及其所有内容(子目录和所有目录)将被复制到一个称为“构建上下文”的暂存区域中。当您在Dockerfile中发出COPY
指令时,Docker将从暂存区复制到映像文件系统中的一层。
如您所见,这将导致从构建上下文外部的目录中复制文件。
解决方法
要么在构建过程中将它们所需的文件从其黄金源直接下载到映像中(这就是为什么您经常在Dockerfiles中看到很多curl
语句的原因),或者您可以复制所需的文件(目录)进入构建树并作为项目的一部分将其检入源代码管理。选择哪种方法完全取决于项目的性质和所需的文件。
Notes
为此还记录了其他解决方法,所有这些都无一例外地破坏了构建的“可移植性”的意图。唯一优质的解决方案是这里记录的解决方案(不过,如果我错过了保留可移植性的解决方案,我很乐意将其添加到此列表中。)