Mercurial > public > mercurial-scm > hg-stable
comparison tests/tinyproxy.py @ 16300:74e114ac6ec1 stable
tests: fix startup/shutdown races in test-https
tinyproxy now writes its own pid when it's ready to accept connections
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 28 Mar 2012 19:23:25 -0500 |
parents | 0b21ae0a2366 |
children | 7292a4618f46 |
comparison
equal
deleted
inserted
replaced
16299:853ffcafecfa | 16300:74e114ac6ec1 |
---|---|
10 Any help will be greatly appreciated. SUZUKI Hisao | 10 Any help will be greatly appreciated. SUZUKI Hisao |
11 """ | 11 """ |
12 | 12 |
13 __version__ = "0.2.1" | 13 __version__ = "0.2.1" |
14 | 14 |
15 import BaseHTTPServer, select, socket, SocketServer, urlparse | 15 import BaseHTTPServer, select, socket, SocketServer, urlparse, os |
16 | 16 |
17 class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): | 17 class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): |
18 __base = BaseHTTPServer.BaseHTTPRequestHandler | 18 __base = BaseHTTPServer.BaseHTTPRequestHandler |
19 __base_handle = __base.handle | 19 __base_handle = __base.handle |
20 | 20 |
120 do_POST = do_GET | 120 do_POST = do_GET |
121 do_PUT = do_GET | 121 do_PUT = do_GET |
122 do_DELETE = do_GET | 122 do_DELETE = do_GET |
123 | 123 |
124 class ThreadingHTTPServer (SocketServer.ThreadingMixIn, | 124 class ThreadingHTTPServer (SocketServer.ThreadingMixIn, |
125 BaseHTTPServer.HTTPServer): pass | 125 BaseHTTPServer.HTTPServer): |
126 def __init__(self, *args, **kwargs): | |
127 BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs) | |
128 a = open("proxy.pid", "w") | |
129 a.write(str(os.getpid()) + "\n") | |
130 a.close() | |
126 | 131 |
127 if __name__ == '__main__': | 132 if __name__ == '__main__': |
128 from sys import argv | 133 from sys import argv |
129 if argv[1:] and argv[1] in ('-h', '--help'): | 134 if argv[1:] and argv[1] in ('-h', '--help'): |
130 print argv[0], "[port [allowed_client_name ...]]" | 135 print argv[0], "[port [allowed_client_name ...]]" |