У меня есть рабочая функция dummy_proc, определенная, как показано ниже:
Код: Выделить всё
def regex_check(input_string):
# Pattern to match both "pm_lat" and "pm_lon_coslat" followed by two floats
pattern = r"(check1|check2)_(-?\d+\.\d+)_(-?\d+\.\d+)"
# Find all matches of the pattern in the input string
matches = re.findall(pattern, input_string)
# 'matches' is a list of tuples, each containing the keyword and the two matched float values
matches = ["_".join(match) for match in matches]
return matches
def dummy_proc(str1, str2
group1: str,
group2: str,
) -> bool:
"""performs a simple regex check.
Args:
group1 (string): The first group of ROIs.
group2 (string): The second group of ROIs.
Returns:
bool: True if no two item in the two lists combined are the same.
"""
group1_srs = regex_check(group1)
group2_srs = regex_check(group2)
return len(set(group1_srs).intersection(set(group2_srs))) == 0
Код: Выделить всё
with Pool(processes=12) as pool:
result = pool.starmap(dummy_proc, [(pair[0], pair[1]) for pair in pairs])
Я что-то упустил? Разве я не должен ожидать, что при использовании htop будет отображено 12 процессов?
PS: Это MWE.
Подробнее здесь: https://stackoverflow.com/questions/788 ... -processes