Skip to content

Instantly share code, notes, and snippets.

@nonZero
Created September 27, 2017 06:27
Show Gist options
  • Save nonZero/09a3d9d5ca3266d0cddd26583e72c626 to your computer and use it in GitHub Desktop.
Save nonZero/09a3d9d5ca3266d0cddd26583e72c626 to your computer and use it in GitHub Desktop.
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