i just noticed that when i run a pyqt application and close it, the application closes , but the process is still alive. Apparently the process that was running does not close even after closing the application.
Traceback (most recent call last):
File "F:\Projects\XYZ\XYZ\XYZ.py", line 414, in <module>
sys.exit(app.exec_())
SystemExit: 0
When i searched online , its says that if the return value is 0 , it is a normal termination. As you see the process keep on pilling up as i run the application.
So how do i overcome this problem?
SOLUTION
This a quick fix , that i was able to make to solve this problem.
import psutil, os
def kill_proc_tree(pid, including_parent=True):
parent = psutil.Process(pid)
for child in parent.children(recursive=True):
child.kill()
if including_parent:
parent.kill()
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow() # <-- Instantiate QMainWindow object.
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
app.exec_()
me = os.getpid()
kill_proc_tree(me)
This looks like a problem specific to IDLE.
There are several issues on the python bug tracker that are closely related (e.g. 8093 and 12540), but they are now closed and resolved as "fixed".
Since it appears that you are using a very old version of python (2.5), you should be able to solve the problem by upgrading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With