<commit_before># Network-related helper functions.

# Return an available random local port
local_tcp_port() {
    # shellcheck disable=SC2039
    local port pid
<commit_msg>tests: Add alternative TCP port finder<commit_after># Network-related helper functions.

# Return an available random local port
local_tcp_port() {
    if which python3 >/dev/null 2>&1; then
        (
            cat << EOF
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 0))
print(s.getsockname()[1])
s.close()
EOF
        ) | python3
        return
    fi

    # shellcheck disable=SC2039
    local port pid

{'fraction_non_alphanumeric': 0.1024, 'fraction_numerical': 0.032, 'mean_word_length': 3.22972972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3702106', 'n_tokens_mistral': 208, 'n_tokens_neox': 196, 'n_words': 58}