Github user jsirois commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/850#discussion_r52766421
  
    --- Diff: lib/py/test/test_sslsocket.py ---
    @@ -42,22 +43,50 @@
     CLIENT_KEY = os.path.join(ROOT_DIR, 'test', 'keys', 'client_v3.key')
     CLIENT_CA = os.path.join(ROOT_DIR, 'test', 'keys', 'CA.pem')
     
    -TEST_PORT = 23458
    -TEST_ADDR = '/tmp/.thrift.domain.sock.%d' % TEST_PORT
    -CONNECT_DELAY = 0.5
    -CONNECT_TIMEOUT = 20.0
     TEST_CIPHERS = 'DES-CBC3-SHA'
     
     
     class ServerAcceptor(threading.Thread):
         def __init__(self, server):
             super(ServerAcceptor, self).__init__()
    +        self.daemon = True
             self._server = server
    -        self.client = None
    +        self._listening = threading.Event()
    +        self._port = None
    +        self._port_bound = threading.Event()
    +        self._client = None
    +        self._client_accepted = threading.Event()
     
         def run(self):
             self._server.listen()
    -        self.client = self._server.accept()
    +        self._listening.set()
    +
    +        try:
    +            address = self._server.handle.getsockname()
    +            if len(address) > 1:
    +                # AF_INET addresses are 2-tuples (host, port) and AF_INET6 
are
    +                # 4-tuples (host, port, ...), but in each case port is in 
the second slot.
    +                self._port = address[1]
    +        finally:
    +            self._port_bound.set()
    +
    +        try:
    +            self._client = self._server.accept()
    +        finally:
    +            self._client_accepted.set()
    +
    +    def await_listening(self, timeout=None):
    +        self._port_bound.wait(timeout=timeout)
    +
    +    @property
    +    def port(self, timeout=None):
    --- End diff --
    
    Aha - gotcha, will do.  One more diff coming.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to