文章詳情頁
python如何手動實現(xiàn)阻塞
瀏覽:189日期:2022-08-10 10:24:43
問題描述
python 如何手動實現(xiàn)阻塞?
令py腳本一直阻塞直到強制退出(KeyboardInterrupt)
之前用
while True: pass
發(fā)現(xiàn)cpu占用太高了。。。
問題解答
回答1:1. 使用time.sleepwhile True: # 等待一年 time.sleep(60*60*24*365) # 直接等待一百年time.sleep(60*60*24*365*100)2.使用threading.Condition
condition=threading.Condition()condition.acquire()condition.wait()2.使用等待鍵盤響應(yīng)
Python實現(xiàn)按任意鍵繼續(xù)
回答2:while True: time.sleep(1)
上一條:python - 用scrapy-splash爬取網(wǎng)站 為啥iframe下的內(nèi)容沒有被返回下一條:python - 用BeautifulSoup如何提取data-lazy-src屬性?
相關(guān)文章:
1. boot2docker無法啟動2. docker-compose中volumes的問題3. java - SSH框架中寫分頁時service層中不能注入分頁類4. docker容器呢SSH為什么連不通呢?5. dockerfile - 為什么docker容器啟動不了?6. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.7. nignx - docker內(nèi)nginx 80端口被占用8. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值9. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””10. 關(guān)于docker下的nginx壓力測試
排行榜

熱門標簽
網(wǎng)公網(wǎng)安備