![](/img/trans.png)
[英]Error when sending a HTTPS post request using Python's requests library with a proxy
[英]'Request' library hangs temporarily when sending POST requests to the server?! [Python]
我有每10秒将数据发送到服务器的python代码。 我的朋友也有相同类型的代码,但是在C语言中。我正在使用requests
库。 我有时发现,当我发送数据时,我的代码有时会挂起。
您可以看到在386到400之间,只有SRDEAFUALT1234正在发送,而1.5-PC(我的代码)挂起了
import requests
import time
while True:
start_time_loop = time.time()
source = requests.get(url)
result = source.json()
resp = request.post(another_url.php,json = result,headers)
if time.time()-start_time_loop> 10: pass
else : time.sleep(abs(10 - (time.time() - start_time_loop)))
我的代码中有什么东西使它滞后吗? 我应该修改一些东西以获得更好的连接和性能吗?
我建议将pass替换为print'timeout'以查看会发生什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.