def countTranscribeJobsInState(status, client, filesLimit):
    """
    Queries Transcribe for the number of jobs with the given status.  If there are more than 100
    then this will need multiple queries until we build up the total. If we reach or overshoot
    a specific limit (effectively the queue limit) then stop counting
    """
    response = client.list_transcription_jobs(Status=status)
    found = len(response["TranscriptionJobSummaries"])
    while ("NextToken" in response) and (found <= filesLimit):
        response = client.list_transcription_jobs(Status="IN_PROGRESS", NextToken=response["NextToken"])
        found += len(response["TranscriptionJobSummaries"])

    return found