Skip to content

Commit

Permalink
fix: shutdown application on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Nov 13, 2023
1 parent df0e0d4 commit c6b632b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions silverback/application.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import atexit
from datetime import timedelta
from typing import Callable, Dict, Optional, Union
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c6b632b

Please sign in to comment.