correctly close API objects during testing

This commit is contained in:
Sarah Hoffmann
2023-12-05 21:20:57 +01:00
parent 615b166c68
commit 8791c6cb69
2 changed files with 17 additions and 8 deletions

View File

@@ -29,9 +29,12 @@ async def convert(project_dir: Path, outfile: Path, options: Set[str]) -> None:
outapi = napi.NominatimAPIAsync(project_dir,
{'NOMINATIM_DATABASE_DSN': f"sqlite:dbname={outfile}"})
async with api.begin() as src, outapi.begin() as dest:
writer = SqliteWriter(src, dest, options)
await writer.write()
try:
async with api.begin() as src, outapi.begin() as dest:
writer = SqliteWriter(src, dest, options)
await writer.write()
finally:
await outapi.close()
finally:
await api.close()