Re: [問題] exception的疑問

看板Python作者 (請多指教!!)時間14年前 (2010/08/02 09:50), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串2/3 (看更多)
我發現另一個問題了 我的 class 可能會在很多function丟出 Exception 如果是一般的functioin我可以正常接到 但是如果在 thread裡面丟出的話就接不到了 這是我的sample code from threading import Thread import time class T(Thread): def __init__(self): Thread.__init__(self) def run(self): print 'thread' time.sleep(1) raise Exception('kill') try: app = T() app.start() except Exception: print 'Catch kill' 我的猜測是在 try中 三個fun都執行完沒問題 所以就跳出 try / except這個部分了 然後thread在很久很久之後才出現exception 這時候就抓不到 我的理解有錯嗎 = =? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.91.77

08/02 11:06, , 1F
看完這篇我好奇你心中的 thread 是什麼?
08/02 11:06, 1F

08/02 11:20, , 2F
一個process額外產生的小東西 他會自己跑自己的
08/02 11:20, 2F
文章代碼(AID): #1CLYH_Rl (Python)
文章代碼(AID): #1CLYH_Rl (Python)