Fokko commented on code in PR #1941:
URL: https://github.com/apache/iceberg-python/pull/1941#discussion_r2053725060
##########
tests/catalog/test_hive.py:
##########
@@ -183,6 +192,61 @@ def hive_database(tmp_path_factory:
pytest.TempPathFactory) -> HiveDatabase:
)
+class SaslServer(threading.Thread):
+ def __init__(self, socket: thrift.transport.TSocket.TServerSocket,
response: bytes) -> None:
+ super().__init__()
+ self.daemon = True
+ self._socket = socket
+ self._response = response
+ self._port = None
+ self._port_bound = threading.Event()
+
+ def run(self) -> None:
+ self._socket.listen()
+
+ try:
+ address = self._socket.handle.getsockname()
+ # AF_INET addresses are 2-tuples (host, port) and AF_INET6 are
+ # 4-tuples (host, port, ...), i.e. port is always at index 1.
+ _host, self._port, *_ = address
+ finally:
+ self._port_bound.set()
+
+ # Accept connections and respond to each connection with the same
message.
+ # The responsibility for closing the connection is on the client
+ while True:
+ try:
+ client = self._socket.accept()
+ if client:
+ client.write(self._response)
+ client.flush()
+ except Exception:
+ logging.exception(
+ "An error occurred while responding to client",
+ )
Review Comment:
That works for me 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]