Kevin Barry added the comment:
emmanuel,
The Python interpreter isn't reentrant, so you could only run two interactive
sessions connected to the same Python environment if you implemented your own
REPL function that unlocked the GIL when waiting for input, then lock it just
long enou
Kevin Barry added the comment:
emmanuel,
Regarding your points: All three can be taken care of with a combination of my
patch and setting sys.stdin, sys.stdout, and sys.stderr to the pty. (That
should really be done internally with another patch, since os.fdopen is
OS-specific. Also
Kevin Barry added the comment:
One additional issue, which my patch doesn't address, is that
PyRun_InteractiveLoop should really take *two* FILE* arguments, with the second
one being optional. This is because on Linux (and presumably on other *nixes)
if a read operation is blocked on a
Kevin Barry added the comment:
emmanuel,
Thanks for the suggestion. Your workaround is exactly the same as using dup2
(in C) to replace stdin/stdout/stderr with the pty, however. If you added the
following lines to your C code, it would have the same effect as the
command-line redirection in
Kevin Barry added the comment:
I still see the potential cause addressed by my patch in the 2.7, 3.3, and
"default" branches, so I'm assuming that all versions from 2.6 on have this
problem.
I also see that I can elect to change the "Status" and "Resolution"
Kevin Barry added the comment:
I've attached a simplified example program (working3.c) that demonstrates both
the original problem and that the patch
(Python-2.6.6-Run_Interactive-fix.patch) works. It eliminates the need for a
pty, 'xterm', and redirection.
Compile the a
Kevin Barry added the comment:
The patch from before needed a slight modification for when Python actually
defaults to an interactive session on stdin. Since I rebuild this for my
current distro (Slackware64 13.37,) I switched to the Python 2.6.6 source. This
might not be the proper way to
Kevin Barry added the comment:
I've attached a new example source file to demonstrate the fix.
Compile the attached program with (*after* patching and installing Python):
> gcc `python-config --cflags` working2.c -o working2 `python-config --ldflags`
and run it with:
> ./workin
Kevin Barry added the comment:
Here is a patch that corrects the problem (quoted below and attached.) This
only corrects the problem when 'PyOS_ReadlineFunctionPointer' is set, e.g. you
must 'import readline', otherwise Python will defer to stdin/stdout with
'PyOS_St
New submission from Kevin Barry :
I have been trying to get PyRun_InteractiveLoop to run on a pty (Linux) without
replacing stdin and stdout with that pty; however, it seems like Python (2.6.6)
is hard-coded to only run interactively on stdin and stdout.
Compile the attached program with
10 matches
Mail list logo