2012-12-09 38 views
1

雖然試圖在Python中使用thread,用下面的代碼Python和線程 - 進口未定義的變量:start_new_thread

import select, sys, time, thread 

TIMEOUT = 30 

def listenthread(server,result): 

# some code 
# 
# 

def main(argv=None): 
    if argv is None: 
     argv = sys.argv[1:] 
    server = Server()    
    clientaddrs = [] 
    # listen to clients in new thread 
    thread.start_new_thread(listenthread, (server,clientaddrs)) # that line produces a problem 

我得到Undefined variable from import: start_new_thread當我到達行:

thread.start_new_thread(listenthread, (server,clientaddrs)) 

什麼可能是問題嗎?

Regards

回答

2

這是一個常見的PyDev錯誤。我發現你的代碼沒有錯,PyDev只是提醒你一個不存在的錯誤。

查看答案列表herehere