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
|
import argparse
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
from csv_exporter import export_vereine
|
from csv_exporter import export_vereine
|
||||||
from verein import Verein
|
from verein import Verein
|
||||||
|
@ -18,12 +19,9 @@ def main():
|
||||||
verein_ids = get_verein_ids_near_location(args.latitude, args.longitude)
|
verein_ids = get_verein_ids_near_location(args.latitude, args.longitude)
|
||||||
|
|
||||||
print("Getting Verein information")
|
print("Getting Verein information")
|
||||||
vereine: [Verein] = []
|
vereine: [Verein]
|
||||||
for verein_id in verein_ids:
|
with ThreadPoolExecutor() as executor:
|
||||||
try:
|
vereine = list(executor.map(get_verein_for_id, verein_ids))
|
||||||
vereine.append(get_verein_for_id(verein_id))
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print("Exporting Verein information")
|
print("Exporting Verein information")
|
||||||
export_vereine(vereine, args.export_file)
|
export_vereine(vereine, args.export_file)
|
||||||
|
|
Loading…
Reference in a new issue