<commit_before>import aiomcache
import aioredis
import asyncio
import gc
import pytest
import time
import uuid
from docker import Client as DockerClient
import socket


@pytest.fixture(scope='session')
def unused_port():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("", 0))
    s.listen(1)
    port = s.getsockname()[1]
    s.close()
    return port


@pytest.fixture(scope='session')
def loop(request):
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(None)

    yield loop

    if not loop._closed:
        loop.call_soon(loop.stop)
        loop.run_forever()
        loop.close()
    gc.collect()
    asyncio.set_event_loop(None)


@pytest.fixture(scope='session')
def session_id():
    """Unique session identifier, random string."""
    return str(uuid.uuid4())


@pytest.fixture(scope='session')
def docker():
    return DockerClient(version='auto')


def pytest_addoption(parser):
    parser.addoption("--no-pull", action="store_true", default=False,
                     help="Don't perform docker images pulling")


@pytest.fixture(scope='session')
def redis_server(docker, session_id, loop, request):
    if not request.config.option.no_pull:
        docker.pull('redis:{}'.format('latest'))

    """
    container = docker.create_container(
        image='redis:{}'.format('latest'),
        name='redis-test-server-{}-{}'.format('latest', session_id),
        ports=[6379],
        detach=True,
    )
    """

    container_args = dict(
        image='redis:{}'.format('latest'),
        name='redis-test-server-{}-{}'.format('latest', session_id),
        ports=[6379],
        detach=True,
    )

    # bound IPs do not work on OSX
    host = "127.0.0.1"
    host_port = unused_port()
    container_args['host_config'] = docker.create_host_config(
        port_bindings={6379: (host, host_port)})

    container = docker.create_container(**container_args)

    docker.start(container=container['Id'])
    # inspection = docker.inspect_container(container['Id'])
    # host = inspection['NetworkSettings']['IPAddress']
    delay = 0.001
    for i in range(100):
        try:
            conn = loop.run_until_complete(
                aioredis.create_connection((host, host_port), loop=loop)
            )<commit_msg>Drop comment<commit_after>import aiomcache
import aioredis
import asyncio
import gc
import pytest
import time
import uuid
from docker import Client as DockerClient
import socket


@pytest.fixture(scope='session')
def unused_port():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("", 0))
    s.listen(1)
    port = s.getsockname()[1]
    s.close()
    return port


@pytest.fixture(scope='session')
def loop(request):
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(None)

    yield loop

    if not loop._closed:
        loop.call_soon(loop.stop)
        loop.run_forever()
        loop.close()
    gc.collect()
    asyncio.set_event_loop(None)


@pytest.fixture(scope='session')
def session_id():
    """Unique session identifier, random string."""
    return str(uuid.uuid4())


@pytest.fixture(scope='session')
def docker():
    return DockerClient(version='auto')


def pytest_addoption(parser):
    parser.addoption("--no-pull", action="store_true", default=False,
                     help="Don't perform docker images pulling")


@pytest.fixture(scope='session')
def redis_server(docker, session_id, loop, request):
    if not request.config.option.no_pull:
        docker.pull('redis:{}'.format('latest'))

    container_args = dict(
        image='redis:{}'.format('latest'),
        name='redis-test-server-{}-{}'.format('latest', session_id),
        ports=[6379],
        detach=True,
    )

    # bound IPs do not work on OSX
    host = "127.0.0.1"
    host_port = unused_port()
    container_args['host_config'] = docker.create_host_config(
        port_bindings={6379: (host, host_port)})

    container = docker.create_container(**container_args)

    docker.start(container=container['Id'])
    # inspection = docker.inspect_container(container['Id'])
    # host = inspection['NetworkSettings']['IPAddress']
    delay = 0.001
    for i in range(100):
        try:
            conn = loop.run_until_complete(
                aioredis.create_connection((host, host_port), loop=loop)
            )
{'fraction_non_alphanumeric': 0.14034275127373785, 'fraction_numerical': 0.012505789717461788, 'mean_word_length': 3.297512437810945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1155308', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1362, 'n_words': 266}