Skip to content

Commit b5628ac

Browse files
committed
fix: Add timer for import GeoJson
1 parent 3d48c74 commit b5628ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

osm_rawdata/importer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def importThread(
6969
data (list): The list of tiles to download
7070
db
7171
"""
72-
log.debug(f"In importThread()")
72+
# log.debug(f"In importThread()")
7373
#timer = Timer(text="importThread() took {seconds:.0f}s")
7474
#timer.start()
7575
ways = table(
@@ -89,9 +89,9 @@ def importThread(
8989
)
9090

9191
index = 0
92-
log.debug(f"DATA:{index} {len(data)}")
92+
9393
for feature in data:
94-
log.debug(feature)
94+
# log.debug(feature)
9595
index -= 1
9696
entry = dict()
9797
tags = feature['properties']
@@ -304,6 +304,9 @@ def importGeoJson(
304304
index = 0
305305
connections = list()
306306

307+
timer = Timer(text="importGeoJson() took {seconds:.0f}s")
308+
timer.start()
309+
307310
for thread in range(0, cores + 1):
308311
engine = create_engine(f"postgresql://{self.dburi}", echo=False)
309312
if not database_exists(engine.url):
@@ -321,6 +324,7 @@ def importGeoJson(
321324

322325
if entries <= chunk:
323326
result = importThread(data['features'], connections[0])
327+
timer.stop()
324328
return True
325329

326330
with concurrent.futures.ThreadPoolExecutor(max_workers=cores) as executor:
@@ -331,6 +335,8 @@ def importGeoJson(
331335
block += chunk
332336
index += 1
333337
executor.shutdown()
338+
timer.stop()
339+
334340
return True
335341

336342
def main():

0 commit comments

Comments
 (0)