()
| 596 | |
| 597 | |
| 598 | def get_random_port(): |
| 599 | while True: |
| 600 | port = random.randint(49152, 65535) |
| 601 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: |
| 602 | try: |
| 603 | s.bind(("0.0.0.0", port)) |
| 604 | return port |
| 605 | except OSError: |
| 606 | continue |
| 607 | |
| 608 | |
| 609 | def parse_ports(ports): |