| 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | # SPDX-License-Identifier: Apache-2.0. |
| 3 | |
| 4 | # Helper for test_websocket subprocess scenarios. |
| 5 | # Runs awscrt.websocket.connect() against a host:port given on the command |
| 6 | # line and waits for on_connection_setup to fire. Used by tests that need |
| 7 | # to observe whether a malformed server response crashes the client process. |
| 8 | |
| 9 | import sys |
| 10 | from concurrent.futures import Future |
| 11 | |
| 12 | from awscrt.websocket import connect, create_handshake_request |
| 13 | |
| 14 | TIMEOUT = 10.0 |
| 15 | |
| 16 | |
| 17 | def main(host, port): |
| 18 | setup_future = Future() |
| 19 | connect( |
| 20 | host=host, |
| 21 | port=port, |
| 22 | handshake_request=create_handshake_request(host=host), |
| 23 | on_connection_setup=lambda x: setup_future.set_result(x)) |
| 24 | setup_future.result(TIMEOUT) |
| 25 | |
| 26 | |
| 27 | if __name__ == '__main__': |
| 28 | main(sys.argv[1], int(sys.argv[2])) |