OLD | NEW |
1 # copyright (c) 2012 the chromium authors. all rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # use of this source code is governed by a bsd-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the license file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import multiprocessing | 5 import multiprocessing |
6 import os | 6 import os |
7 | 7 |
8 | 8 |
9 class LocalHTTPServer(object): | 9 class LocalHTTPServer(object): |
10 """Class to start a local HTTP server as a child process.""" | 10 """Class to start a local HTTP server as a child process.""" |
11 | 11 |
12 def __init__(self, serve_dir): | 12 def __init__(self, serve_dir): |
13 parent_conn, child_conn = multiprocessing.Pipe() | 13 parent_conn, child_conn = multiprocessing.Pipe() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 httpd = BaseHTTPServer.HTTPServer(('', 0), | 56 httpd = BaseHTTPServer.HTTPServer(('', 0), |
57 SimpleHTTPServer.SimpleHTTPRequestHandler) | 57 SimpleHTTPServer.SimpleHTTPRequestHandler) |
58 conn.send(httpd.server_address[1]) # the chosen port number | 58 conn.send(httpd.server_address[1]) # the chosen port number |
59 httpd.timeout = 0.5 # seconds | 59 httpd.timeout = 0.5 # seconds |
60 running = True | 60 running = True |
61 while running: | 61 while running: |
62 httpd.handle_request() | 62 httpd.handle_request() |
63 if conn.poll(): | 63 if conn.poll(): |
64 running = conn.recv() | 64 running = conn.recv() |
65 conn.close() | 65 conn.close() |
OLD | NEW |