Created
September 27, 2017 06:27
-
-
Save nonZero/09a3d9d5ca3266d0cddd26583e72c626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
import subprocess | |
import sys | |
import time | |
import os | |
print("hello!", sys.argv) | |
def foo(e): | |
print("hi") | |
e.wait() | |
print("bye") | |
if __name__ == '__main__': | |
print("main") | |
mp.set_start_method('spawn') | |
e = mp.Event() | |
p = mp.Process(target=foo, args=(e,)) | |
p.start() | |
time.sleep(0.5) | |
cmd = "pstree -a {}".format(os.getpid()) | |
print(subprocess.check_output(cmd, shell=True, universal_newlines=True)) | |
e.set() | |
p.join() | |
print("done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment