forked from hans/Nominatim
make NominatimAPI[Async] a context manager
If close() isn't properly called, it can lead to odd error messages about uncaught exceptions.
This commit is contained in:
@@ -40,10 +40,9 @@ async def conn(table_factory):
|
||||
table_factory('word',
|
||||
definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB')
|
||||
|
||||
api = NominatimAPIAsync(Path('/invalid'), {})
|
||||
async with api.begin() as conn:
|
||||
yield conn
|
||||
await api.close()
|
||||
async with NominatimAPIAsync(Path('/invalid'), {}) as api:
|
||||
async with api.begin() as conn:
|
||||
yield conn
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user