Louie NRT Story

[Raspberry Pi] Subprocess(Run new process) 본문

에너지

[Raspberry Pi] Subprocess(Run new process)

hyeok0724.kim@gmail.com 2019. 10. 28. 19:05
반응형

Writed on 28 OCT 2019
Device: Raspberry Pi 3
Raspbian Version: 2019-09-26-raspbian-buster-full.zip

1. exec

if __name__ == "__main__":
    exec(open("test01.py").read())

 

2. subprocess

import os
import signal
import subprocess

if __name__ == "__main__":
    proc = subprocess.Popen("python test01.py", shell=True)
    pid_ = proc.pid
    os.system('kill -9 %s' %pid_)

 

Reference: https://docs.python.org/3/library/subprocess.html

 

subprocess — Subprocess management — Python 3.8.0 documentation

subprocess — Subprocess management Source code: Lib/subprocess.py The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several older modules and fu

docs.python.org

반응형

'에너지' 카테고리의 다른 글

[Raspberry Pi] Chromium-browser Autostart  (0) 2019.11.04
[Raspberry Pi] php web server  (0) 2019.11.04
[Raspberry Pi] Supervisor  (0) 2019.10.28
[Raspberry Pi] Watchdog  (0) 2019.10.28
[Raspberry Pi] Change booting image and remove log  (0) 2019.10.23
Comments