Merge pull request #121 from AulonSal/close-tortoise-connections

Close Tortoise connections properly
This commit is contained in:
long2ice 2021-02-28 14:47:58 +08:00 committed by GitHub
commit 49897dc4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View File

@ -2,6 +2,10 @@
## 0.5 ## 0.5
### 0.5.1
- Fix tortoise connections not being closed properly. (#120)
### 0.5.0 ### 0.5.0
- Refactor core code, now has no limitation for everything. - Refactor core code, now has no limitation for everything.

View File

@ -1 +1 @@
__version__ = "0.5.0" __version__ = "0.5.1"

View File

@ -35,7 +35,13 @@ def coro(f):
@wraps(f) @wraps(f)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
loop = asyncio.get_event_loop() 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 return wrapper

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "aerich" name = "aerich"
version = "0.5.0" version = "0.5.1"
description = "A database migrations tool for Tortoise ORM." description = "A database migrations tool for Tortoise ORM."
authors = ["long2ice <long2ice@gmail.com>"] authors = ["long2ice <long2ice@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"