python
2021. 8. 9. 12:03
(NG, not good/not working)python subprocess kill on exit
SNMP Viewer / 종료해도 타스크매니저에서 프로세스가 보일때(종료안될때) ,
python subprocess kill on exit
관련 링크:
import atexit process = subprocess.Popen(args.server_file_path) atexit.register(process.terminate) pid = process.pid
- 실제
>subprocess.Popen 으로 호출후 종료시에 서브프로세스를 같이 종료하게 해줌.
> 변경전 소스: ED_SNMP_Setup.py
class LocalSetupDialog(QtWidgets.QDialog): def __init__(self): QtWidgets.QDialog.__init__(self) self.ui = local_setup.Ui_Dialog() self.ui.setupUi(self) self.setupData() self.ui.buttonBox.accepted.connect(self.popupConfirm) self.ui.pushButton.clicked.connect(self.snmpViewer) ...... def snmpViewer(self): self.accept() argList = ['ED_SNMP_Viewer.exe', config['ipAddress'], config['snmpCommunity_read'], config['snmpCommunity_write'], config['snmpPort'], config['trapPort']] |
> 변경후 소스:
class LocalSetupDialog(QtWidgets.QDialog): def __init__(self): QtWidgets.QDialog.__init__(self) self.ui = local_setup.Ui_Dialog() self.ui.setupUi(self) self.setupData() self.ui.buttonBox.accepted.connect(self.popupConfirm) self.ui.pushButton.clicked.connect(self.snmpViewer) ...... def snmpViewer(self): self.accept() argList = ['ED_SNMP_Viewer.exe', config['ipAddress'], config['snmpCommunity_read'], config['snmpCommunity_write'], config['snmpPort'], config['trapPort']] m_process = subprocess.Popen(argList) import atexit atexit.register(m_process.terminate) |
'python' 카테고리의 다른 글
Python UDP CLient / Server example (0) | 2022.12.19 |
---|---|
PyQt - QThread 사용, thread 간 통신 (0) | 2022.04.15 |
PyQt ProgressBar (0) | 2021.08.02 |
filename and line number of Python script (0) | 2021.08.02 |
python UDP socket timeout examples (0) | 2021.08.02 |