Skip to content

Commit

Permalink
Cleanup a mistake in test_httpservers.py, and make a change to the ex…
Browse files Browse the repository at this point in the history
…ample portforwarder to better handle race conditions.
  • Loading branch information
jamadden committed Jan 24, 2018
1 parent 602724f commit 4a00f99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
11 changes: 9 additions & 2 deletions examples/portforwarder.py
Expand Up @@ -47,8 +47,15 @@ def close(self):


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:
Expand Down
15 changes: 9 additions & 6 deletions src/greentest/2.7pypy/test_httpservers.py
Expand Up @@ -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)
Expand Down

0 comments on commit 4a00f99

Please sign in to comment.