I have my python code that sends data to the server every 10 seconds. My friend also has the same type of code but it is in C. I am using requests
library. What I found sometimes was that my code would hang sometimes when I send the data.
You can see at 386 till 400, only SRDEAFUALT1234 was sending while 1.5-PC (my code) hanged or something
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)))
Is there something in my code that makes it lag? Should I modify somthing to get better connection and performance?!
我建议将pass替换为print'timeout'以查看会发生什么。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.