]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api.py
add unit tests for new Python API
[nominatim.git] / nominatim / api.py
index f5e942d1f3377936de57bc9e8afc5d87a533d579..e129c4f8de4e9e13c5f87a9183cc6deabbf14ec4 100644 (file)
@@ -38,6 +38,14 @@ class NominatimAPIAsync:
                                           future=True)
 
 
+    async def close(self) -> None:
+        """ Close all active connections to the database. The NominatimAPIAsync
+            object remains usable after closing. If a new API functions is
+            called, new connections are created.
+        """
+        await self.engine.dispose()
+
+
     async def status(self) -> StatusResult:
         """ Return the status of the database.
         """
@@ -53,6 +61,14 @@ class NominatimAPI:
         self.async_api = NominatimAPIAsync(project_dir, environ)
 
 
+    def close(self) -> None:
+        """ Close all active connections to the database. The NominatimAPIAsync
+            object remains usable after closing. If a new API functions is
+            called, new connections are created.
+        """
+        asyncio.get_event_loop().run_until_complete(self.async_api.close())
+
+
     def status(self) -> StatusResult:
         """ Return the status of the database.
         """