12345678910111213141516171819202122232425262728293031323334353637 |
- import os
- import subprocess
- import multiprocessing
- # Получить ID и текущую директорию процесса
- def test_1():
- print(os.getpid())
- print(os.getcwd())
- print(os.uname())
- # Запуск других программ
- def test_2():
- ret = subprocess.getoutput('date')
- print(ret)
- # Создание процессов
- def whoami(what):
- print('Process %s says: %s' % (os.getpid(), what))
- def create_proc():
- whoami("I'm the main programm")
- for n in range(4):
- p = multiprocessing.Process(target=whoami, args=("I'm function %s" % n,))
- p.start()
- test_1()
- # test_2()
- # create_proc()
|