[svn r37444] a try at a wrapping loop_socketserver.py
that restarts the actual socketserver.py --HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									3d70646122
								
							
						
					
					
						commit
						6d403d4573
					
				|  | @ -0,0 +1,12 @@ | ||||||
|  | 
 | ||||||
|  | import os, sys | ||||||
|  | 
 | ||||||
|  | if __name__ == '__main__': | ||||||
|  |     directory = os.path.dirname(os.path.abspath(sys.argv[0])) | ||||||
|  |     script = os.path.join(directory, 'socketserver.py') | ||||||
|  |     while 1: | ||||||
|  |         cmd = "python %s %s" % (script, " ".join(sys.argv[1:])) | ||||||
|  |         print "starting subcommand:", cmd | ||||||
|  |         f = os.popen(cmd) | ||||||
|  |         for line in f: | ||||||
|  |             print line, | ||||||
|  | @ -53,7 +53,7 @@ def bind_and_listen(hostport): | ||||||
|         old = fcntl.fcntl(serversock.fileno(), fcntl.F_GETFD) |         old = fcntl.fcntl(serversock.fileno(), fcntl.F_GETFD) | ||||||
|         fcntl.fcntl(serversock.fileno(), fcntl.F_SETFD, old | fcntl.FD_CLOEXEC) |         fcntl.fcntl(serversock.fileno(), fcntl.F_SETFD, old | fcntl.FD_CLOEXEC) | ||||||
|     # allow the address to be re-used in a reasonable amount of time |     # allow the address to be re-used in a reasonable amount of time | ||||||
|     if os.name == 'posix' and sys.platform != 'cygwin': |     #if os.name == 'posix' and sys.platform != 'cygwin': | ||||||
|     serversock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |     serversock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||||||
|          |          | ||||||
|     serversock.bind(hostport) |     serversock.bind(hostport) | ||||||
|  | @ -83,5 +83,5 @@ if __name__ == '__main__': | ||||||
|     else: |     else: | ||||||
|         hostport = ':8888' |         hostport = ':8888' | ||||||
|     serversock = bind_and_listen(hostport) |     serversock = bind_and_listen(hostport) | ||||||
|     startserver(serversock, loop=True) |     startserver(serversock, loop=False) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue