Answer the question
In order to leave comments, you need to log in
How to multithread, using executor.map, pass many parameters to the function, and iterate one?
There is a brute function (code enumeration) that starts iteration by a separate function
def checkCode(session, code, code_for_url, referer):
pass
def bruteCode(s, url_code, referer):
start_code = 110000
end_code = 111000
for code in range(start_code, end_code + 1):
s, success = checkCode(s, code, url_code, referer) # проверяем код
if success:
return code
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(concurrency) as executor:
for _ in executor.map(upload, queryset):
pass
worker = 10
with ThreadPoolExecutor(worker) as executor:
# и дальше затык.
# 1. Как мне передать в executor.map свою checkCode c кучей параметров,
# но где будет постоянно меняться параметр code
# 2. Как мне указать диапазон?
# 3. В примере стоит в цикле pass, мне тоже нужно писать pass?
for code in range(start_code, end_code + 1):
s, success = checkCode(s, code, url_code, referer) # проверяем код
if success:
return code
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question