summaryrefslogtreecommitdiff
path: root/threads
diff options
context:
space:
mode:
Diffstat (limited to 'threads')
-rw-r--r--threads/about_process.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/threads/about_process.py b/threads/about_process.py
new file mode 100644
index 0000000..eafa4fd
--- /dev/null
+++ b/threads/about_process.py
@@ -0,0 +1,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()