In Python 2.3.x C/C++ API, the souce file Parser/myreadline.c in
function PyOS_Readline() says:
/* This is needed to handle the unlikely case that the
* interpreter is in interactive mode *and* stdin/out are not
* a tty. This can happen, for example if python is run like
* this: python -i < test1.py
*/
if (!isatty (fileno (sys_stdin)) || !isatty (fileno (sys_stdout)))
rv = PyOS_StdioReadline (sys_stdin, sys_stdout, prompt);
else */
rv = (*PyOS_ReadlineFunctionPointer)(sys_stdin, sys_stdout,
prompt);
When sys_stdin or sys_stdout are not a tty, there is not way of calling
the readline function pointer.
I am working in a parallelized version of the Python interpreter, and I
used the pointer to implement a specialized version of the readline
function: it reads input in 'root' process (using the original readline
function) and broadcasts string data to slaves.
Some MPI implementations (i.e. MPICH) don seems to have stdin and
stdout connected to a tty in processes other than the 'master' or 'root'
one, being impossible to me to override the input mechanism.
My workaround was patching the sources, eliminating the if/else lines..
There is another way of handling the cases like
$ python -i < test1.py ????
Am I forgetting something?
Thanks in advance....
|