def METHOD_NAME(
    event, services_by_dependencies, soa_dir, synapse_service_dir
):
    filename = event[3].decode()
    log.debug(f"process_inotify_event on {filename}")
    service_instance, suffix = os.path.splitext(filename)
    if suffix != ".json":
        return
    services_to_update = services_by_dependencies.get(service_instance, ())
    if not services_to_update:
        return
    # filter active_service_groups() down to just the names in services_to_update
    service_groups = {
        service_group: macs
        for service_group, macs in firewall.active_service_groups().items()
        if service_group in services_to_update
    }
    try:
        with firewall.firewall_flock():
            firewall.ensure_service_chains(service_groups, soa_dir, synapse_service_dir)
        for service_to_update in services_to_update:
            log.debug(f"Updated {service_to_update}")
    except TimeoutError as e:
        log.error(
            "Unable to update firewalls for {} because time-out obtaining flock: {}".format(
                service_groups.keys(), e
            )
        )