pexpect / ptyprocess

Run a subprocess in a pseudo terminal
https://ptyprocess.readthedocs.io/en/latest/
Other
217 stars 71 forks source link

PtyProcess.spawn just got slower and can trigger problems #52

Open cagney opened 5 years ago

cagney commented 5 years ago

This is somewhat related to #43.

Python 3.7.1 contains the change https://bugs.python.org/issue6721 that is trying to avoid a deadlock in the logging code. It works by having os.fork() grab all the logging locks before executing fork(). It's expensive - if the forked process is just going to exec then os.spawn() is preferred. Its also creating, lets say, interesting problems (deadlocks) with code that was working.

Since PtyProcess calls pty.fork() (which calls os.fork() ...) it triggering this code path.

Using some equivalent of os.spawn() would eliminate this.

takluyver commented 5 years ago

I don't know how to combine the os.spawn* functions - or anything that doesn't involve a fork - with setting up a new pty as the controlling terminal of the child process. I suspect it's not possible, but it would be very nice if it was. If you figure it out, please let me know!

cagney commented 5 years ago

This is probably obsolete, #53 completely avoids fork().