Skip to content

shell.system() hangs executing Python #53

@davidm-ro

Description

@davidm-ro

python-hanging.zip

See the attached sample Train script for a repro (macOS 15.5, using Python 3.11.4.)

Both these commands will never return and you need to press Ctrl+C to terminate the train script:

shell.system("python3 -c \"print('Hello World')\"", ".");

shell.system("python3 test.py --validate-only", ".");

Expected:

Both those print 'Hello world' and train moves on.

Observed:

You'll see the following printed to console, and nothing else. You'll need to press Ctrl+C to continue.

  shell.system()(python3 -c "print('Hello World')" WD: /Users/work/...) { ...

and the same behaviour for the second one too.

Files

I can't attach train or Python files, so they are:

python-hanging.train:

// Bug Report: shell.system() hangs when executing Python scripts
// 
// Expected: Python script should execute and return output
// Actual: shell.system() hangs indefinitely when calling Python scripts
// 
// This affects any Python script execution, making it impossible to use
// Python-based systems with Train.

log("Testing simple Python command...");
try {
    var result = shell.system("python3 -c \"print('Hello World')\"", ".");
    log("Result: " + result);
} catch (e) {
    log("Error: " + e);
}

log("Testing Python script file...");
try {
    var result = shell.system("python3 test.py --validate-only", ".");
    log("Result: " + result);
} catch (e) {
    log("Error: " + e);
}

log("Test completed - if you see this, the bug was fixed");

and test.py:

#!/usr/bin/env python3

def main():
    print("Hello, World!")

if __name__ == "__main__":
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions