Skip to content
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

print() 在有阻塞的情况下无法打印 #19

Closed
HWZen opened this issue Mar 25, 2022 · 2 comments
Closed

print() 在有阻塞的情况下无法打印 #19

HWZen opened this issue Mar 25, 2022 · 2 comments

Comments

@HWZen
Copy link

HWZen commented Mar 25, 2022

下面样式的代码

print("something");

socket.recv(); //或是别的会引发阻塞的代码

会导致print()无法打印,或打印不完全
如print("Hello")会打印成Hel
在阻塞结束后继续打印

在Qt环境下大概率无法打印

@HWZen
Copy link
Author

HWZen commented Mar 25, 2022

难道print()是把内容存到缓冲区,然后专门有个线程去打印缓冲区的吗?

@trcrsired
Copy link
Member

trcrsired commented Mar 25, 2022

手工fflush(stdout)或者flush(fast_io::c_stdout())。

它在缓冲区里没写。

如果只是为了非缓冲输出,应该输出到fast_io::out(),而不是默认的fast_io::c_stdout()。
或者输出到fast_io::dbg(),会输出到windbg或是安卓adb

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