The telnet client dead in calling select function.
The telnet client is called by a expect script.
The expect script is called by subprocess.Popen
The subprocess.Popen is called by mod_wsgi
There is no problem if call the expect script directly.
There is no problem if call the subprocess.Popen from a python program.
When the subprocess.Popen is called from the mod_wsgi, the telnet client hung up in waiting the return of select
Is there some restriction for the sub process of mod_wsgi?
Why the select not work if it is the sub process of mod_wsgi?
The code detail is:
Code piece of python:
ScriptRun.BACKEND_PROCESS = subprocess.Popen(“/tmp/expect_shell.sh”, shell=True)
return ScriptRun.BACKEND_PROCESS
Code piece of /tmp/expect_shell.sh:
spawn telnet $ipaddr;
set timeout 10 ;
expect \
{
timeout \
{
send_user "time out";
exit 10;
}
default \
{
send_user "ok";
exit 10;
}
}
After execution of “spawn telnet $ipaddr;”, the telnet client did not output anything.
Code piece of telnet:
c = select(16, &ibits, &obits, &xbits,(poll == 0) ? NULL : &TimeValue);
Add trace in the telnet client source code, I find the program blocked in the select function when call from mod_wsgi
Thanks in advance.