Commit 8ac8febe authored by Jason Madden's avatar Jason Madden

Per @tilgovi in issue gevent/gevent#248, try the path of adapting the example...

Per @tilgovi in issue gevent/gevent#248, try the path of adapting the example portforwarder to work like gunicorn and don't expect the lifetime of the socket to outlast the invocation of the spawned handle method. Down to 10 total failures, only one unexpected.
parent 57e5762f
...@@ -31,9 +31,11 @@ class PortForwarder(StreamServer): ...@@ -31,9 +31,11 @@ class PortForwarder(StreamServer):
except IOError as ex: except IOError as ex:
log('%s:%s failed to connect to %s:%s: %s', address[0], address[1], self.dest[0], self.dest[1], ex) log('%s:%s failed to connect to %s:%s: %s', address[0], address[1], self.dest[0], self.dest[1], ex)
return return
gevent.spawn(forward, source, dest) forwarders = (gevent.spawn(forward, source, dest),
gevent.spawn(forward, dest, source) gevent.spawn(forward, dest, source))
# XXX only one spawn() is needed # if we return from this method, the stream will be closed out
# from under us, so wait for our children
gevent.joinall(forwarders)
def close(self): def close(self):
if self.closed: if self.closed:
......
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