Skip to content

对于stream交互式接口的理解 #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
duchx opened this issue Apr 30, 2025 · 3 comments
Closed

对于stream交互式接口的理解 #145

duchx opened this issue Apr 30, 2025 · 3 comments

Comments

@duchx
Copy link

duchx commented Apr 30, 2025

我理解交互式的意思应该是程序运行有输入时等待输入,有输出时及时输出。
但是我实际使用下来发现(使用python)
比如
input("等待输入:")
仍然直接:
Nonzero Exit Status

比如
import time
print(1);
time.sleep(5);
print(2);

仍然是等程序执行完返回最终结果
1
2
而不是先输出1等待5秒后再输出2

不知道是不是我用法不对?还是本身就是这么设计的

@criyle
Copy link
Owner

criyle commented Apr 30, 2025

您可以查看在线 demo https://goj.ac/terminal 或者 使用 go-judge-shell 测试

@duchx
Copy link
Author

duchx commented May 1, 2025

嗯嗯,可以了。感谢回复和解答。
另有办法判断当前程序是等待输入状态吗,比如python中input或者c++中std::cin时客户端如何感知应该发起3 - input类型的调用

@criyle
Copy link
Owner

criyle commented May 1, 2025

您应当和和用户程序协商好通讯协议,包括输入和输出的内容以及顺序。由于管道通讯自带缓存,并不能可靠的判断输入是否被读取或者是否在等待读取。

@criyle criyle closed this as completed May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants