Skip to content

Commit cfcd2ba

Browse files
committed
update parallel scripts
1 parent e791a95 commit cfcd2ba

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

script_parallel_1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from scrapers.scraper import connect_to_base, get_driver, parse_html, write_to_file
88

99

10-
def run_process(filename, headless):
10+
def run_process(number, filename, headless):
1111

1212
# init browser
1313
browser = get_driver(headless)
@@ -39,9 +39,9 @@ def run_process(filename, headless):
3939
output_timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
4040
output_filename = f"output_{output_timestamp}.csv"
4141

42-
# scrape and craw
42+
# scrape and crawl
4343
with Pool(cpu_count() - 1) as p:
44-
p.starmap(run_process, repeat(output_filename), repeat(headless)))
44+
p.starmap(run_process, zip(range(1, 21), repeat(output_filename), repeat(headless)))
4545
p.close()
4646
p.join()
4747

script_parallel_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from scrapers.scraper import connect_to_base, get_driver, parse_html, write_to_file
77

88

9-
def run_process(filename, headless):
9+
def run_process(number, filename, headless):
1010

1111
# init browser
1212
browser = get_driver(headless)
@@ -43,7 +43,7 @@ def run_process(filename, headless):
4343
with ProcessPoolExecutor() as executor:
4444
for number in range(1, 21):
4545
futures.append(
46-
executor.submit(run_process, output_filename, headless)
46+
executor.submit(run_process, number, output_filename, headless)
4747
)
4848

4949
wait(futures)

0 commit comments

Comments
 (0)