Created
August 1, 2023 13:10
-
-
Save jaraco/d171fabf56dec50dfdc9d2060800d509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
import threading | |
locks = lock, rlock = threading.Lock(), threading.RLock() | |
with lock, rlock: | |
child = os.fork() | |
if child: | |
raise SystemExit(0) | |
if lock.locked(): | |
print(lock, 'is locked') | |
if rlock._is_owned(): | |
print(rlock, 'is locked') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment