summaryrefslogtreecommitdiff
path: root/threads/about_process.py
blob: eafa4fd714fbf83d501d1ddfd97db56abe0c0380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

from multiprocessing import Process
import os
import time


def run():
    while True:
        print(f'current process id: {os.getpid()}')
        print(f'parent process id of current process {os.getpid()}: {os.getppid()}')
        time.sleep(2)


def run2():
    while True:
        print(f'current process id: {os.getpid()}')
        print(f'parent process id of current process {os.getpid()}: {os.getppid()}')
        time.sleep(2)


if __name__ == '__main__':
    p1 = Process(target=run)
    p1.start()
    p2 = Process(target=run2)
    p2.start()