AcademySoftwareFoundation / AcademySoftwareFoundation/rez

120 returncode executing Python code from a ResolvedContext within Maya 2022

Open
#1,193 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.1k
Forks
374
Avg merge
9d 12h
Merged PRs (30d)
5

Description

Hi!

I've run into an issue running Python 3.7.4 code within a ResolvedContext in Maya 2022.3, where it errors and returns a returncode of 120. It looks like this return code indicates an error with the interpreter shutting down.
https://bugs.python.org/issue5319

**Rez version:** 2.103.4

**Reproduction steps**
Run the following snippet in the Maya Script Editor
```
from rez.resolved_context import ResolvedContext
context = ResolvedContext(["python"])
process = context.execute_command(args=['python', '-c', "import sys; print(sys.path)"])
print(process.communicate())
print(process.returncode)
```
```
>>> (None, None)
>>> 120
```

**Workaround**

The issue can be worked around fairly simply by redirecting the stdout and stderr for the Popen to subprocess.PIPE, e.g
```
from rez.resolved_context import ResolvedContext
context = ResolvedContext(["python"])
process = context.execute_command(args=['python', '-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
```

Let me know if there's any more information I can provide!

Thanks,
Nikhil

Contributor guide

Open the contributing guide

Research direction

Start with rez.resolved_context.ResolvedContext.execute_command and reproduce the Maya 2022.3 case using the provided Python snippet. Compare process behavior with and without stdout and stderr pipes; done means the command completes without the unexpected returncode 120 while retaining usable output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.