def parentonly(func):
def wrapper(*args, **kwargs):<EOL><INDENT>pid = os.getpid()<EOL>if pid == parent_pid:<EOL><INDENT>return func(*args, **kwargs)<EOL><DEDENT><DEDENT>wrapper.__name__ = func.__name__<EOL>return wrapper<EOL>
Only execute the decorated function in the parent thread.