diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 23:15:51 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 23:15:51 +0000 |
commit | f86b8c399390b0ca6852f2fcecb1dcc564be178f (patch) | |
tree | 976a6bd6a544b9a8da00e938853719ca1b0c4fe2 /native_client_sdk | |
parent | ec05af504dcd00ae27e30741730383a173411ab6 (diff) | |
download | chromium_src-f86b8c399390b0ca6852f2fcecb1dcc564be178f.zip chromium_src-f86b8c399390b0ca6852f2fcecb1dcc564be178f.tar.gz chromium_src-f86b8c399390b0ca6852f2fcecb1dcc564be178f.tar.bz2 |
NaCl SDK: Nicer error message for httpd start.
If creating the HTTPServer fails, today an exception is thrown, saying
that httpd isn't defined. This can happen if a user accidentally tries
to start multiple httpd.py processes.
After this patch, we get a more descriptive error message when failing:
$ ./httpd.py
Error creating HTTPServer: [Errno 98] Address already in use
Traceback (most recent call last):
File "./httpd.py", line 306, in <module>
sys.exit(main(sys.argv[1:]))
File "./httpd.py", line 298, in main
options.test_mode)
File "./httpd.py", line 176, in __init__
raise Exception('Unable to launch HTTP server.')
Exception: Unable to launch HTTP server.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11421033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/tools/httpd.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/native_client_sdk/src/tools/httpd.py b/native_client_sdk/src/tools/httpd.py index 8057f91..8735e49 100755 --- a/native_client_sdk/src/tools/httpd.py +++ b/native_client_sdk/src/tools/httpd.py @@ -10,6 +10,7 @@ import multiprocessing import optparse import os import SimpleHTTPServer # pylint: disable=W0611 +import socket import sys import time import urlparse @@ -252,6 +253,11 @@ def _HTTPServerProcess(conn, dirname, port, server_kwargs): os.chdir(dirname) httpd = PluggableHTTPServer(('', port), PluggableHTTPRequestHandler, **server_kwargs) + except socket.error as e: + sys.stderr.write('Error creating HTTPServer: %s\n' % e) + sys.exit(1) + + try: conn.send(httpd.server_address[1]) # the chosen port number httpd.timeout = 0.5 # seconds while httpd.running: |