]> git.ipfire.org Git - location/libloc.git/commitdiff
importer: No longer import Geofeeds concurrently
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 12:06:33 +0000 (12:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 12:06:33 +0000 (12:06 +0000)
This is kind of a problem since many servers have gone away, respond
very slowly, etc. But since we are moving towards psycopg3, we cannot do
this the old way any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 7003f4f84167de05ee7f6f3fb18138b8bde1e27d..6571f39ee142471a06eddec32ada70b1a21b7106 100644 (file)
@@ -18,7 +18,6 @@
 ###############################################################################
 
 import argparse
-import concurrent.futures
 import csv
 import functools
 import http.client
@@ -1600,6 +1599,9 @@ class CLI(object):
                                yield line
 
        def handle_update_geofeeds(self, ns):
+               # Create a downloader
+               downloader = location.importer.Downloader()
+
                # Sync geofeeds
                with self.db.transaction():
                        # Delete all geofeeds which are no longer linked
@@ -1647,18 +1649,10 @@ class CLI(object):
                                id
                """)
 
-               # Create a downloader
-               downloader = location.importer.Downloader()
-
-               # Pass the downloader to the fetch_geofeed function
-               fetch_geofeed = functools.partial(self._fetch_geofeed, downloader)
-
-               with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
-                       results = executor.map(fetch_geofeed, geofeeds)
-
-                       # Fetch all results to raise any exceptions
-                       for result in results:
-                               pass
+               # Update all geofeeds
+               for geofeed in geofeeds:
+                       with self.db.transaction():
+                               self._fetch_geofeed(downloader, geofeed)
 
                # Delete data from any feeds that did not update in the last two weeks
                with self.db.transaction():