Parallelize verein fetching
This commit is contained in:
parent
acdcf98896
commit
89dbaeb092
1 changed files with 4 additions and 6 deletions
10
main.py
10
main.py
|
@ -1,4 +1,5 @@
|
|||
import argparse
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from csv_exporter import export_vereine
|
||||
from verein import Verein
|
||||
|
@ -18,12 +19,9 @@ def main():
|
|||
verein_ids = get_verein_ids_near_location(args.latitude, args.longitude)
|
||||
|
||||
print("Getting Verein information")
|
||||
vereine: [Verein] = []
|
||||
for verein_id in verein_ids:
|
||||
try:
|
||||
vereine.append(get_verein_for_id(verein_id))
|
||||
except RuntimeError:
|
||||
pass
|
||||
vereine: [Verein]
|
||||
with ThreadPoolExecutor() as executor:
|
||||
vereine = list(executor.map(get_verein_for_id, verein_ids))
|
||||
|
||||
print("Exporting Verein information")
|
||||
export_vereine(vereine, args.export_file)
|
||||
|
|
Loading…
Reference in a new issue