Python の stdin を使用して、他のプロセスからのメッセージを受信します
ただし、高速受信メッセージの stdin バフ サイズを変更したい
サブプロセスプロセスを開くときに、サブプロセスが標準入力バフを設定できることを知っています
しかし、私のプロセスの1つは、メッセージを送信するacプロセスです
もう 1 つは、メッセージを受信する python プロセスです。
Pythonでstdinバフサイズを変更するにはどうすればよいですか?
私のホストはLinuxマシンです..
同様の質問への回答から:
Python の -u フラグを使用して、stdin/stdout からバッファリングを完全に削除できます。
-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) see man page for details on internal buffering relating to '-u'そしてmanページは明確にします:
-u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xread- lines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop.
それ以外は、(十分にまたは広く) サポートされていません。