trouble with sys.exec and sockets/ssh

Donn Cave donn at u.washington.edu
Fri Feb 21 14:52:39 EST 2003


Quoth Richard Cook <rcook at llnl.gov>:

| I have a problem as follows.  I call an executable with os.execv(cmd, 
| args) and it launches fine.  However, it then misbehaves.  The normal 
| behavior of the program is to fork off children, each of which execs 
| another process (ssh), which creates a process on a remote machine, 
| which connects back to the main process using a socket connection 
| over TCP/IP or UDP.  This works fine every time from the shell 
| command line.  But it fails from my python script.  The behavior when 
| I fork it off using os.execv in python is that the socket connections 
| back "home" from the children fail. Not all of them fail, just many 
| of them.  (If any fail, it's a disaster for me.)  Clearly the 
| environment that the process I execv from python sees is somehow 
| different than that seen by the same process if I run it from the 
| shell.  Can anyone guess as to what I'm doing wrong or not 
| understanding?  Thank you.

What does "the socket connections ... fail" mean?   They abort
with "Connection refused" errors?

I don't really have much of a clue, and you may have to post an
example program before anyone sees the problem.  But one thing
you might try is a little delay - put a time.sleep(1.0) between
the forks, the real idea being to stagger the incoming connections
a little.  If that helps but isn't attractive, you might be able
to deal with the problem by increasing the listen() value.

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list