1

I use python's stdin to recv message from other process

but want to change the stdin buff size for fast recv message

I know the subprocee can set the stdin buff when open a subprocess process

but One of my process is a c process whice send message

the other is a python process which recv message

how can i change the stdin buff size in python?

my host is a linux machine..

timger
  • 944
  • 2
  • 13
  • 31

1 Answers1

0

From an answer to a similar question:

You can completely remove buffering from stdin/stdout by using python's -u flag:

-u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
         see man page for details on internal buffering relating to '-u'

and the man page clarifies:

  -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.

Other than that, it is not (well or widely) supported.

Community
  • 1
  • 1