#StackBounty: #python #python-3.x #future How to make future calls and wait until complete with Python?

Bounty: 250

I have the following code where I have a list of usernames and I try and check if the users are in a specific Windows Usergroup using net user domain | find somegroup.

The problem is that I run that command for about 8 usergroups per username and it is slow. I would like to send off these calls using futures and even separate threads (if it makes it quicker).

I just have to wait at the end before i do anything else. How do I go about doing it in Python?

for one_username in user_list:
    response = requests.get(somecontent)

    bs_parsed = BeautifulSoup(response.content, 'html.parser')

    find_all2 = bs_parsed.find("div", {"class": "QuickLinks"})
    name = re.sub("ss+", ' ', find_all2.find("td", text="Name").find_next_sibling("td").text)

    find_all = bs_parsed.find_all("div", {"class": "visible"})
    all_perms = ""
    d.setdefault(one_username + " (" + name + ")", [])
    for value in find_all:
        test = value.find("a", {"onmouseover": True})
        if test is not None:
            if "MyAppID" in test.text:
                d[one_username + " (" + name + ")"].append(test.text)

    for group in groups:
        try:
            d[one_username + " (" + name + ")"].append(check_output("net user /domain " + one_username + "| find "" + group + """, shell=True, stderr=subprocess.STDOUT).strip().decode("utf-8"))
        except Exception:
            pass


Get this bounty!!!