criyle / go-judge

Sandbox Server in REST / gRPC API. Based on Linux container technologies.
MIT License
419 stars 67 forks source link

我在运行python程序时遇到了问题 #101

Closed renyumeng1 closed 6 months ago

renyumeng1 commented 6 months ago

请求参数如下:

{
    "cmd": [
        {
            "args": [
                "/usr/bin/python3",
                "main.py"
            ],
            "env": [
                "PATH=/usr/bin:/bin"
            ],
            "files": [
                {
                    "name": "stdout",
                    "max": 10240,
                    "content": "1 1\n"
                },
                {
                    "name": "stderr",
                    "max": 10240
                }
            ],
            "cpuLimit": 3000000000,
            "clockLimit": 4000000000,
            "memoryLimit": 104857600,
            "procLimit": 50,
            "cpuRate": 0.1,
            "copyIn": {
                "main.py": {
                    "content": "a = input()\nprint(a)"
                }
            }
        }
    ]
}

返回如下

[
    {
        "status": "Nonzero Exit Status",
        "exitStatus": 1,
        "time": 60886044,
        "memory": 3592192,
        "runTime": 62178151,
        "files": {
            "stderr": ""
        }
    }
]

我只有在使用input()函数时会报错,其余时候都是正常的

criyle commented 6 months ago

你的 stdin 呢?files 应该是类似

[
{"content": "1 1\n"},
{
"name": "stdout",
"max": 10240
},
{
"name": "stderr",
"max": 10240
}
]
renyumeng1 commented 6 months ago

感谢作者大大的回答,我刚才在debug的时候发现了我content放错位置了