This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/extract_reveiew_metadata_update
- Loading branch information
Showing
464 changed files
with
22,561 additions
and
2,399 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Launch process that is not child process of python or OpenPype. | ||
This is written for linux distributions where process tree may affect what | ||
is when closed or blocked to be closed. | ||
""" | ||
|
||
import os | ||
import sys | ||
import subprocess | ||
import json | ||
|
||
|
||
def main(input_json_path): | ||
"""Read launch arguments from json file and launch the process. | ||
Expected that json contains "args" key with string or list of strings. | ||
Arguments are converted to string using `list2cmdline`. At the end is added | ||
`&` which will cause that launched process is detached and running as | ||
"background" process. | ||
## Notes | ||
@iLLiCiT: This should be possible to do with 'disown' or double forking but | ||
I didn't find a way how to do it properly. Disown didn't work as | ||
expected for me and double forking killed parent process which is | ||
unexpected too. | ||
""" | ||
with open(input_json_path, "r") as stream: | ||
data = json.load(stream) | ||
|
||
# Change environment variables | ||
env = data.get("env") or {} | ||
for key, value in env.items(): | ||
os.environ[key] = value | ||
|
||
# Prepare launch arguments | ||
args = data["args"] | ||
if isinstance(args, list): | ||
args = subprocess.list2cmdline(args) | ||
|
||
# Run the command as background process | ||
shell_cmd = args + " &" | ||
os.system(shell_cmd) | ||
sys.exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Expect that last argument is path to a json with launch args information | ||
main(sys.argv[-1]) |
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
Oops, something went wrong.