# Buggy code
def from_config(cls, name, config_data, client):
    """
    Construct a Project from a config.Config object.
    """
    use_networking = config_data.version and config_data.version != V1
    networks = build_networks(name, config_data, client)
    project_networks = ProjectNetworks.from_services(
        config_data.services, networks, use_networking
    )
    volumes = ProjectVolumes.from_config(name, config_data, client)
    project = cls(name, [], client, project_networks, volumes, config_data.version)

    for service_dict in config_data.services:
        service_dict = dict(service_dict)
        if use_networking:
            service_networks = get_networks(service_dict, networks)
        else:
            service_networks = {}

        service_dict.pop("networks", None)
        links = project.get_links(service_dict)
        network_mode = project.get_network_mode(
            service_dict, list(service_networks.keys())
        )
        pid_mode = project.get_pid_mode(service_dict)
        volumes_from = get_volumes_from(project, service_dict)

        if config_data.version != V1:
            service_dict["volumes"] = [
                volumes.namespace_spec(volume_spec)
                for volume_spec in service_dict.get("volumes", [])
            ]

        secrets = get_secrets(
            service_dict["name"],
            service_dict.pop("secrets", None) or [],
            config_data.secrets,
        )

        project.services.append(
            Service(
                service_dict.pop("name"),
                client=client,
                project=name,
                use_networking=use_networking,
                networks=service_networks,
                links=links,
                network_mode=network_mode,
                volumes_from=volumes_from,
                secrets=secrets,
                pid_mode=pid_mode,
                **service_dict,
            )
        )

    return project


# 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 from_config(cls, name, config_data, client, global_parallel_limit=None):
    """
    Construct a Project from a config.Config object.
    """
    use_networking = config_data.version and config_data.version != V1
    networks = build_networks(name, config_data, client)
    project_networks = ProjectNetworks.from_services(
        config_data.services, networks, use_networking
    )
    volumes = ProjectVolumes.from_config(name, config_data, client)
    project = cls(
        name,
        [],
        client,
        project_networks,
        volumes,
        config_data.version,
        parallel_limit=global_parallel_limit,
    )

    for service_dict in config_data.services:
        service_dict = dict(service_dict)
        if use_networking:
            service_networks = get_networks(service_dict, networks)
        else:
            service_networks = {}

        service_dict.pop("networks", None)
        links = project.get_links(service_dict)
        network_mode = project.get_network_mode(
            service_dict, list(service_networks.keys())
        )
        pid_mode = project.get_pid_mode(service_dict)
        volumes_from = get_volumes_from(project, service_dict)

        if config_data.version != V1:
            service_dict["volumes"] = [
                volumes.namespace_spec(volume_spec)
                for volume_spec in service_dict.get("volumes", [])
            ]

        secrets = get_secrets(
            service_dict["name"],
            service_dict.pop("secrets", None) or [],
            config_data.secrets,
        )

        project.services.append(
            Service(
                service_dict.pop("name"),
                client=client,
                project=name,
                use_networking=use_networking,
                networks=service_networks,
                links=links,
                network_mode=network_mode,
                volumes_from=volumes_from,
                secrets=secrets,
                pid_mode=pid_mode,
                **service_dict,
            )
        )

    return project