![](/img/trans.png)
[英]PicklingError: Can't pickle <class 'module'>: attribute lookup module on builtins failed
[英]pickle.PicklingError: Can't pickle <class 'module'>: attribute lookup module on builtins failed
我是python的新手,正在嘗試在一個類中使用多重處理。 我嘗試使用線程來做到這一點,並且它可以工作,但是當我將其更改為多處理時,它出現了以下所示的錯誤。 我嘗試使用多處理而非線程的原因是,多處理具有.terminate(),而線程沒有。 請幫幫我,謝謝!
碼:
class PageMenu(tk.Frame):
def __init__(self, parent, controller):
def startRolling(times):
theProcess = multiprocessing.Process(target = fa.main, args = (fa.roles[choice.get()], times))
theProcess.start()
tk.Frame.__init__(self, parent)
textFeed = tk.IntVar()
textField = tk.Entry(self, textvariable = textFeed)
textField.place(x = 165, y = 170)
button7 = tk.Button(self, text="=-=-=Start=-=-=", command = lambda: startRolling(textFeed.get()),font = LARGE_FONT)
button7.place(x = 165, y = 200)
錯誤:_pickle.PicklingError:無法酸洗:內置的屬性查找模塊失敗
錯誤的完整版本在下面的鏈接中
multiprocessing
不能替代線程。
在通過multiprocessing
處理創建的進程中運行的代碼在與創建它的進程不同的進程中運行。 因此,它無法訪問與Tk GUI相關的對象; 這些對象僅在父進程中有效。
如果需要終止線程,請使用條件變量來通知該線程該停止了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.