I HAVE THIS PYTHON PROGRAMM: [test]$ cat socpb.py import BaseHTTPServer, SocketServer, os, socket, threading # the server initialisation server = SocketServer.TCPServer((socket.gethostname(), 8088),BaseHTTPServer.BaseHTTPRequestHandler) t=threading.Thread(target=server.serve_forever) t.setDaemon(1) t.start() # the command os.system("sleep 3600") [test]$ I LAUNCH IT: [test]$ python socpb.py [1]+ Stopped python socpb.py [test]$ bg [1]+ python socpb.py & I LOOK THE PORT IT USE --> OK: [test]$ netstat -taupe | grep 8088 tcp 0 0 test:8088 *:* LISTEN mik 32481 14092/python I KILL THE PYTHON PROGRAMM (OR IT STOP BY ANOTHER WAY): [test]$ kill 14092 [test]$ [1]+ Terminated python socpb.py I LOOK THE PORT --> NOK, I EXPECTED THAT THE PORT WAS FREED BUT SLEEP IS LISTENING AND IF I TRY TO LAUNCH MY PROGRAMM, IT FAIL: [test]$ netstat -taupe | grep 8088 tcp 0 0 test:8088 *:* LISTEN mik 32481 14094/sleep [test]$ python socpb.py Traceback (most recent call last): File "socpb.py", line 4, in ? server = SocketServer.TCPServer((socket.gethostname(), 8088),BaseHTTPServer.BaseHTTPRequestHandler) File "/usr/local/lib/python2.3/SocketServer.py", line 330, in __init__ self.server_bind() File "/usr/local/lib/python2.3/SocketServer.py", line 341, in server_bind self.socket.bind(self.server_address) File "<string>", line 1, in bind socket.error: (98, 'Address already in use')
IF I KILL THE SLEEP, ALL COME BACK FINE: [test]$ kill 14094 [test]$ netstat -taupe | grep 8088 [test]$ python socpb.py I HAVE SEARCHED ON THE WEB HOW TO LAUNCH THE SLEEP WHITHOUT IT GET THE PORT IN THE ENVIRONNEMENT BUT NOTHING... I HAVE A WORKAROUND BY USING rsh BUT I AM NOT VERY PLEASED WITH THAT. DOES SOMEONE HAS AN IDEA ? -- http://mail.python.org/mailman/listinfo/python-list