WSL: python simplehttpserver hangs

  • A brief description ‘python -m SimpleHTTPServer 8000’ hangs

  • Expected results should serve files normally

  • Actual results (with terminal output if applicable) The server hangs, requiring a ctrl-c to get it past whatever is blocking it.

Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [13/Apr/2017 14:15:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:15:42] "GET /bower_components/webcomponentsjs/webcomponents-lite.min.js HTTP/1.1" 200 -
^C----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51223)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 310, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python2.7/socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
----------------------------------------
127.0.0.1 - - [13/Apr/2017 14:15:57] "GET /src/shop-app.html HTTP/1.1" 200 -



^C----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51224)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 310, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python2.7/socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
----------------------------------------
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /images/shop-icon-32.png HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-category-data.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-home.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-image.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-button.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /images/mens_outerwear.jpg HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /images/ladies_outerwear.jpg HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /images/mens_tshirts.jpg HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /images/ladies_tshirts.jpg HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/lazy-resources.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-cart-data.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-analytics.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-cart-modal.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:03] "GET /src/shop-icons.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-snackbar.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-tabs.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-tab.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-network-warning.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-404-warning.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-cart-item.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/iron-form/iron-form.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/paper-spinner/paper-spinner-lite.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/app-storage/app-localstorage/app-localstorage-document.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-select.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-tabs-overlay.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /src/shop-ripple-container.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/paper-spinner/paper-spinner-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/paper-spinner/paper-spinner-styles.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/app-storage/app-storage-behavior.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/promise-polyfill/promise-polyfill.html HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2017 14:16:04] "GET /bower_components/promise-polyfill/Promise-Statics.js HTTP/1.1" 200 -
  • Your Windows build number 15063.138

  • Steps / All commands required to reproduce the error from a brand new installation

  1. install node/npm (recommend nvm) and bower (I’m using node v7.8.0 and bower 1.8.0)
  2. npm install -g polymer-cli@next
  3. mkdir tmp && cd tmp
  4. polymer init
  5. choose the shop
  6. let it install
  7. run `python -m SimpleHTTPServer 8000
  8. open IE11 on localhost:8000

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

The python bug report I linked contains technical discussion about why this bug happens and there has already been a patch. https://bugs.python.org/issue31639 It was merged into python 3.7. Looks like no one has made a backport for any earlier versions of python however.

I suppose since this was a python bug and has been addressed by the python team…this could probably be closed with a note that says “issue fixed in python 3.7”.