Commit 4a00f998 authored by Jason Madden's avatar Jason Madden

Cleanup a mistake in test_httpservers.py, and make a change to the example...

Cleanup a mistake in test_httpservers.py, and make a change to the example portforwarder to better handle race conditions.
parent 602724fc
......@@ -47,8 +47,15 @@ class PortForwarder(StreamServer):
def forward(source, dest, server):
source_address = '%s:%s' % source.getpeername()[:2]
dest_address = '%s:%s' % dest.getpeername()[:2]
try:
source_address = '%s:%s' % source.getpeername()[:2]
dest_address = '%s:%s' % dest.getpeername()[:2]
except socket.error as e:
# We could be racing signals that close the server
# and hence a socket.
log("Failed to get all peer names: %s", e)
return
try:
while True:
try:
......
......@@ -668,21 +668,24 @@ def test_main(verbose=None):
# tests are incredibly slow or hang in shutdown for unknown
# reasons
import greentest
MySimpleHTTPRequestHandlerTestCase = SimpleHTTPRequestHandlerTestCase
MySimpleHTTPServerTestCase = SimpleHTTPServerTestCase
MyCGIHTTPServerTestCase = CGIHTTPServerTestCase
if greentest.PYPY and greentest.WIN:
class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
class MySimpleHTTPRequestHandlerTestCase(unittest.TestCase):
def setUp(self):
raise unittest.SkipTest("gevent: Hangs")
def test_empty(self):
return
SimpleHTTPServerTestCase = SimpleHTTPRequestHandlerTestCase
CGIHTTPServerTestCase = SimpleHTTPRequestHandlerTestCase
MySimpleHTTPServerTestCase = MySimpleHTTPRequestHandlerTestCase
MyCGIHTTPServerTestCase = MySimpleHTTPRequestHandlerTestCase
try:
cwd = os.getcwd()
test_support.run_unittest(BaseHTTPRequestHandlerTestCase,
SimpleHTTPRequestHandlerTestCase,
MySimpleHTTPRequestHandlerTestCase,
BaseHTTPServerTestCase,
SimpleHTTPServerTestCase,
CGIHTTPServerTestCase
MySimpleHTTPServerTestCase,
MyCGIHTTPServerTestCase
)
finally:
os.chdir(cwd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment