From c6b632b01c5c5b11cce11e8d5c64cf0bf7ab500e Mon Sep 17 00:00:00 2001 From: doggie <3859395+fubuloubu@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:43:12 -0500 Subject: [PATCH] fix: shutdown application on exit --- silverback/application.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/silverback/application.py b/silverback/application.py index b75f7b96..f88342f0 100644 --- a/silverback/application.py +++ b/silverback/application.py @@ -1,3 +1,4 @@ +import asyncio import atexit from datetime import timedelta from typing import Callable, Dict, Optional, Union @@ -56,6 +57,10 @@ def __init__(self, settings: Optional[Settings] = None): # NOTE: This allows using connected ape methods e.g. `Contract` provider = self.network.__enter__() + def shutdown(): + asyncio.run(self.shutdown()) + + atexit.register(shutdown) atexit.register(self.network.__exit__) self.signer = settings.get_signer()