diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc0a6a..e6cd0e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.5 +### 0.5.1 + +- Fix tortoise connections not being closed properly. (#120) + ### 0.5.0 - Refactor core code, now has no limitation for everything. diff --git a/aerich/__init__.py b/aerich/__init__.py index 3d18726..dd9b22c 100644 --- a/aerich/__init__.py +++ b/aerich/__init__.py @@ -1 +1 @@ -__version__ = "0.5.0" +__version__ = "0.5.1" diff --git a/aerich/cli.py b/aerich/cli.py index ba0353f..e4d3cf7 100644 --- a/aerich/cli.py +++ b/aerich/cli.py @@ -35,7 +35,13 @@ def coro(f): @wraps(f) def wrapper(*args, **kwargs): loop = asyncio.get_event_loop() - loop.run_until_complete(f(*args, **kwargs)) + + # Close db connections at the end of all all but the cli group function + try: + loop.run_until_complete(f(*args, **kwargs)) + finally: + if f.__name__ != "cli": + loop.run_until_complete(Tortoise.close_connections()) return wrapper diff --git a/pyproject.toml b/pyproject.toml index a0f1dec..031d3f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aerich" -version = "0.5.0" +version = "0.5.1" description = "A database migrations tool for Tortoise ORM." authors = ["long2ice "] license = "Apache-2.0"