第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

python檢查在不同類(lèi)中啟動(dòng)的線(xiàn)程

python檢查在不同類(lèi)中啟動(dòng)的線(xiàn)程

富國(guó)滬深 2022-06-07 16:44:04
我很好奇如何獲取已在 python 中的單獨(dú)類(lèi)中啟動(dòng)的線(xiàn)程的狀態(tài)。所以目前我有:class VideoCapture:     def record:         Thread(name='uploading', target=self.upload, args=(upload_queue)).start()在一個(gè)單獨(dú)的文件main.py中,我有一個(gè)VideoCapture. 我希望能夠通過(guò)鍵入類(lèi)似VideoCapture.uploading.isAlive(). 但是我收到 VideoCapture 沒(méi)有上傳對(duì)象的錯(cuò)誤。那么我怎樣才能訪(fǎng)問(wèn)它呢?
查看完整描述

2 回答

?
繁華開(kāi)滿(mǎn)天機(jī)

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊

將線(xiàn)程存儲(chǔ)為類(lèi)的一部分,然后您可以稍后訪(fǎng)問(wèn)它。


class VideoCapture:

    def __init__():

        self.uploading = None

    def record:

       self.uploading = Thread(name='uploading', target=self.upload, args=(upload_queue)).start()

現(xiàn)在在其他地方你有:


video_capture = VideoCapture()

video_capture.record()

if video_capture.uploading.isAlive(): 

    # do something


查看完整回答
反對(duì) 回復(fù) 2022-06-07
?
牛魔王的故事

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個(gè)贊

對(duì)象中有方法is_alive(),Thread所以基本上你只需要使用它:


class VideoCapture:

    def record(self):

        # don't forget to add it on __init__

        self.uploading = Thread(name='uploading', target=self.upload, args=(upload_queue)).start()


tmp = VideoCapture()

tmp.record()

tmp.uploading.is_alive()  # here it is


查看完整回答
反對(duì) 回復(fù) 2022-06-07
  • 2 回答
  • 0 關(guān)注
  • 120 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)