亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 7545 | 回復(fù): 3
打印 上一主題 下一主題

求助:pydev的問(wèn)題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2011-05-30 15:13 |只看該作者 |倒序?yàn)g覽
剛學(xué)python,用pydev寫一個(gè)測(cè)試多線程的小程序,代碼如下:
  1. import thread

  2. def run(n):
  3.     print n

  4. def test():
  5.     thread.start_new_thread(run,(1,))
  6.     thread.start_new_thread(run,(2,))

  7. if __name__=='__main__':
  8.     test()
復(fù)制代碼
在IDLE下運(yùn)行正常,用pydev直接運(yùn)行,提示如下錯(cuò)誤:
Unhandled exception in thread started by
sys.excepthook is missing
lost sys.stderr
Unhandled exception in thread started by
sys.excepthook is missing
lost sys.stderr

求教解決方法

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2011-05-30 20:13 |只看該作者
回復(fù) 1# 0xC1988
  1. if __name__=='__main__':
  2.     test()   
  3.     time.sleep(10)
復(fù)制代碼
thread模塊已經(jīng)不推薦使用了,考慮使用threading模塊。

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2011-05-30 22:43 |只看該作者
謝謝樓上的

論壇徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-07-29 06:20:00
4 [報(bào)告]
發(fā)表于 2011-05-31 09:59 |只看該作者
回復(fù) 1# 0xC1988
可參考一下http://blog.chinaunix.net/space. ... o=blog&id=96074
    threads = {}
    for i in dict_cmd:
        t=threading.Thread(target=write_notes,args=(dict_cmd,log_02,i))
        threads=t
    for i in dict_cmd:
        threads.start()
        time.sleep(2)
    for i in dict_cmd:
        threads.join()
    db_curs.close()
    db_conn.close()
#創(chuàng)建一個(gè)Thread 的實(shí)例,傳給它一個(gè)函數(shù)target,參數(shù)args
#threading是多線程
#三個(gè)循環(huán),將線程都存在threads{}字典中;依次開(kāi)始;程序掛起,直到線程結(jié)束。
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP