# Buggy code
def get_project(
    project_dir,
    config_path=None,
    project_name=None,
    verbose=False,
    host=None,
    tls_config=None,
    environment=None,
    override_dir=None,
):
    if not environment:
        environment = Environment.from_env_file(project_dir)
    config_details = config.find(project_dir, config_path, environment, override_dir)
    project_name = get_project_name(
        config_details.working_dir, project_name, environment
    )
    config_data = config.load(config_details)

    api_version = environment.get(
        "COMPOSE_API_VERSION", API_VERSIONS[config_data.version]
    )

    client = get_client(
        verbose=verbose,
        version=api_version,
        tls_config=tls_config,
        host=host,
        environment=environment,
    )

    with errors.handle_connection_errors(client):
        return Project.from_config(project_name, config_data, client)


# Traceback (IOError)
Exception in thread Thread-5:
Traceback (most recent call last):
File "/compose/build/docker-compose/out00-PYZ.pyz/threading", line 810, in __bootstrap_inner
File "/compose/build/docker-compose/out00-PYZ.pyz/threading", line 763, in run
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.utils", line 31, in inner_execute_function
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 220, in <lambda>
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 173, in create_and_start
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 268, in create_container
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 579, in _get_container_create_options
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 464, in config_hash
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 469, in config_dict
File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 295, in image
File "/compose/build/docker-compose/out00-PYZ.pyz/docker.utils.decorators", line 20, in wrapped
File "/compose/build/docker-compose/out00-PYZ.pyz/docker.client", line 489, in inspect_image
File "/compose/build/docker-compose/out00-PYZ.pyz/docker.clientbase", line 86, in _get
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.sessions", line 477, in get
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.sessions", line 465, in request
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.sessions", line 573, in send
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.adapters", line 370, in send
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.packages.urllib3.connectionpool", line 544, in urlopen
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.packages.urllib3.connectionpool", line 341, in _make_request
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.packages.urllib3.connectionpool", line 761, in _validate_conn
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.packages.urllib3.connection", line 238, in connect
File "/compose/build/docker-compose/out00-PYZ.pyz/requests.packages.urllib3.util.ssl_", line 277, in ssl_wrap_socket
IOError: [Errno 24] Too many open files

# Fixed code
def get_project(
    project_dir,
    config_path=None,
    project_name=None,
    verbose=False,
    host=None,
    tls_config=None,
    environment=None,
    override_dir=None,
):
    if not environment:
        environment = Environment.from_env_file(project_dir)
    config_details = config.find(project_dir, config_path, environment, override_dir)
    project_name = get_project_name(
        config_details.working_dir, project_name, environment
    )
    config_data = config.load(config_details)

    api_version = environment.get(
        "COMPOSE_API_VERSION", API_VERSIONS[config_data.version]
    )

    client = get_client(
        verbose=verbose,
        version=api_version,
        tls_config=tls_config,
        host=host,
        environment=environment,
    )

    global_parallel_limit = environment.get("COMPOSE_PARALLEL_LIMIT")
    if global_parallel_limit:
        global_parallel_limit = int(global_parallel_limit)

    with errors.handle_connection_errors(client):
        return Project.from_config(
            project_name,
            config_data,
            client,
            global_parallel_limit=global_parallel_limit,
        )