Last active
November 25, 2021 22:29
-
-
Save moreati/f93506afa4d6d258b222a1956668ac9a to your computer and use it in GitHub Desktop.
Demonstration of Lock instantiation spawning a subprocess
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
#!/usr/bin/env python3 | |
import multiprocessing | |
import pprint | |
import sys | |
import psutil | |
print("Before", flush=True) | |
pprint.pprint([(p.pid, p.status(), ' '.join(p.cmdline())) for p in psutil.Process().children()]) | |
lock = multiprocessing.Lock() | |
print("After", flush=True) | |
pprint.pprint([(p.pid, p.status(), ' '.join(p.cmdline())) for p in psutil.Process().children()]) |
Author
moreati
commented
Nov 25, 2021
(v310) $ python --version
Python 3.10.0
(v310) $ ./lockprocs.py
Before
[]
After
[(1150,
'running',
'/opt/homebrew/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python '
'-c from multiprocessing.resource_tracker import main;main(4)')]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment