Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

python - Is this the correct way to send multiple arguments to concurrent.futures.ThreadPoolExecutor?

i have to check files in folder structure like this

|_HMR
| |__2015
| |__2016
| |__2017
|
|_TMR1
 |__2015
 |__2016
 |__2017

i use to call my function like this and it works fine

check_continuity('TMR1', 2015)
check_continuity('TMR1', 2016)
check_continuity('TMR1', 2017)
check_continuity('HMR', 2015)
check_continuity('HMR', 2016)
check_continuity('HMR', 2017)

but i would like to make this faster by using multiprocessing (concurrent.futures), so is this a right way to send arguments to my function. since first argument has only two variants and second one has three. and i want first argument to run for three different years and then second argument for three different years.

in short i would like to get the result like my previous way of calling functions individually but faster

am trying to do like this, but looks like its missing few combinations

if __name__ == '__main__':
    with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
        print('creating ThreadPoolExecutor')
        start_scrape1 = executor.map(check_continuity, ('HMR', 'TMR1'), (2015, 2016, 2017))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...