Just the same as the old pure Python subprocess module from Python 2, the PtyProcess.spawn method is not async signal safe. The entire fork() to exec code path must be written in async signal safe C code. Both pty.fork and your own PtyProcess.spawn method violate this constraint.
See the Python 3 subprocess module's _posixsubprocess extension module (and the https://pypi.python.org/pypi/subprocess32/ backport for Python 2 users).
Likely symptoms when this bites you: random seeming deadlocks and hangs.
Workaround for users today: Do not use pexpect.spawn or pexpect.pty_spawn in a multithreaded application.
A pexpect.popen_spawn module appears to exist and will use the subprocess module. If you are on 2.7 make sure you've replaced sys.modules['subprocess'] with a reference to the subprocess32 module first (if you haven't already done so within your Python 2.7 interpreter's stdlib)
Just the same as the old pure Python
subprocessmodule from Python 2, thePtyProcess.spawnmethod is not async signal safe. The entirefork()toexeccode path must be written in async signal safe C code. Bothpty.forkand your ownPtyProcess.spawnmethod violate this constraint.See the Python 3
subprocessmodule's_posixsubprocessextension module (and the https://pypi.python.org/pypi/subprocess32/ backport for Python 2 users).Likely symptoms when this bites you: random seeming deadlocks and hangs.
Workaround for users today: Do not use
pexpect.spawnorpexpect.pty_spawnin a multithreaded application.A
pexpect.popen_spawnmodule appears to exist and will use thesubprocessmodule. If you are on 2.7 make sure you've replaced sys.modules['subprocess'] with a reference to thesubprocess32module first (if you haven't already done so within your Python 2.7 interpreter's stdlib)