1

I have a Python application that uses wxPython and some additional threads. One thread uses PIL.Image.open. Under certain circumstances the application freezes so that you see an uncomplete GUI. I found out that it hangs at PIL.Image.open. When I put debug prints in the PIL module, I can see one time it hangs here, one time there ... -- which I can't understand. It seems totally unrelated.

Is there anything a thread can do in Python, that causes other threads to stop at actually unproblematic lines like import string? Or is wxPython able to give such influence?

4

1 回答 1

3

长时间运行的任务将冻结 GUI,例如 wxPython 或 Tkinter。不过,将长时间运行的进程放入线程通常可以解决问题。我猜您正在线程中以非线程安全的方式与 wxPython 进行通信。如果您没有使用 wx.CallAfter、wx.CallLater 或 wx.PostEvent 从线程与 wxPython 通信,那么这就是问题所在。您必须使用其中一种方法。

否则,我们将需要一个小的可运行示例来诊断问题。

于 2012-07-26T19:18:07.327 回答