我的問題是完成子進程,我使用多進程庫,並在一臺機器與返回或退出線,進程死在加入之前,但在另一臺機器沒有。這個過程一直在增長,他們在完成工作後都沒有完成。在這兩臺機器上,python的版本是2.7.3rc2。python多進程不能正常完成
semaphore_processes_limit = BoundedSemaphore(value=PROCS_LIMIT)
# Starting searches
procs = []
for word in words:
semaphore_processes_limit.acquire()
p = Process(target=searching, args=(word,))
procs.append(p)
p.start()
# Wait for all worker processes to finish
for p in procs:
p.join()
# Process
def searching(word):
return # or exit(0)
謝謝。
最後我找到了原因,但我不明白爲什麼。 當我在子進程中使用隊列對象時,有時候這個隊列會產生另一個子進程,然後這個進程永遠不會死。 –