我在Python 3.7上执行HTTP请求,但是如果我在执行期间遇到一些错误并且脚本停止,则所有新的HTTP请求(甚至在重新启动脚本之后)都会出现错误:[Errno 10054] An existing connection was forcibly closed by the remote host.
我必须禁用/启用我的网络,以删除错误.这可能是由于我的PC/OS,因为该脚本适用于RaspberryPi但不适用于我的Windows 10.但我不知道如何修复它.
这里是生成错误的最小代码:
import requests
import json
import urllib.request
import socket
if __name__ == '__main__':
params = json.dumps({"toto": "ABCD"}).encode('utf-8')
try:
head = {'content-type': 'application/json'}
#replace http by https, to generate the error, re-writte http, and it will never work again
url = 'http://www.google.com'
with requests.post(url, data=params, headers=head) as response:
print("All is OK: " + str(response))
except (urllib.error.URLError, socket.timeout) as e:
print("Error time out: " + …Run Code Online (Sandbox Code Playgroud) 我正在 ARM 项目上实现现代 Cmake。我有 3 个不同的 CMakeList:
target_link_libraries(app_target PUBLIC algo_target hardware_target)
Run Code Online (Sandbox Code Playgroud)
target_compile_options(hardware_target -mcpu=${CPU} -mthumb -mfloat-abi=hard -mfpu=${FPU})
Run Code Online (Sandbox Code Playgroud)
问题是,编译选项传播到顶部,但不在 algo_target 上。我有以下错误:
app 使用 VFP 寄存器参数,algo.a(algo.cpp.obj) 不使用
如何在所有目标上传播编译选项?我不想在编译选项变量中设置编译选项,将来,应用程序将在 2 个不同的硬件目标上运行
我使用GoogleTest,我想用#ifndef里面测试一些函数.
档案交流
bool myFunction() {
#ifndef FOO
return true;
#else
return false;
#endif
}
Run Code Online (Sandbox Code Playgroud)
是否可以在特定测试期间强制#undef?就像我可以在2个统计数据中测试函数(使用define和不使用).