小编P. *_*dre的帖子

脚本重启后现有连接错误

我在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)

python python-3.x

7
推荐指数
1
解决办法
387
查看次数

如何将编译选项从目标传播到 Cmake 上的所有其他目标

我正在 ARM 项目上实现现代 Cmake。我有 3 个不同的 CMakeList:

  • 顶部 CMakeLists:包含要编译的应用程序文件 (main.c) + 2 个目标依赖项(算法和硬件)
target_link_libraries(app_target PUBLIC algo_target hardware_target)
Run Code Online (Sandbox Code Playgroud)
  • algo CMakeLists 只有 C 文件,仅执行计算 (algo.c)
  • hardware CMakeLists 编译有关硬件依赖项的所有文件 (hardware.c) 并根据硬件专门编译选项 -mcpu -mthumb -mfloat-abi -mfpu
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 个不同的硬件目标上运行

c gcc cross-platform cmake target

5
推荐指数
1
解决办法
3049
查看次数

GoogleTest强制#undef进行特定测试

我使用GoogleTest,我想用#ifndef里面测试一些函数.

档案交流

bool myFunction() {
#ifndef FOO
   return true;
#else   
   return false;
#endif
}
Run Code Online (Sandbox Code Playgroud)

是否可以在特定测试期间强制#undef?就像我可以在2个统计数据中测试函数(使用define和不使用).

c embedded googletest

-3
推荐指数
1
解决办法
54
查看次数

标签 统计

c ×2

cmake ×1

cross-platform ×1

embedded ×1

gcc ×1

googletest ×1

python ×1

python-3.x ×1

target ×1