Java中的RequestConfig的Python等价物是什么?

2024-09-28 19:08:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下Java代码:

RequestConfig.custom().setSocketTimeout(10).setConnectTimeout(20).build();

如何在Python中实现相同的功能?你知道吗


Tags: 代码build功能customjavarequestconfigsetconnecttimeoutsetsockettimeout
1条回答
网友
1楼 · 发布于 2024-09-28 19:08:14

请看一下这个answer,这里显示了如何设置timeout。你知道吗

documentation可以看出setSocketTimeoutsetConnectTimeout在Python中是相同的东西。你知道吗

Note that the connect() operation is subject to the timeout setting, and in general it is recommended to call settimeout() before calling connect() or pass a timeout parameter to create_connection(). The system network stack may return a connection timeout error of its own regardless of any Python socket timeout setting.

相关问题 更多 >