Created
December 6, 2019 15:10
-
-
Save schipiga/afdeba76825d2239c63c82a3a7ebc1e1 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 | |
from functools import wraps | |
def waitpid(func): | |
cache = {} | |
@wraps(func) | |
def wrapper(pid, options): | |
try: | |
wpid, status = func(pid, options) | |
if wpid > 0: | |
cache[wpid] = status | |
except OSError as e: | |
if pid in cache: | |
return pid, cache[pid] | |
else: | |
raise e | |
else: | |
return wpid, status | |
return wrapper | |
os.waitpid = waitpid(os.waitpid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment