Skip to content

Commit

Permalink
locking to ensure AWS credentials in Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Cosentino committed Jan 3, 2024
1 parent c33c62c commit 61654f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from telegram import Bot
from telegram.error import TelegramError

from release import __version__ as version
from tracker.config import ConfigHandler

app = FastAPI()
Expand All @@ -16,6 +17,7 @@
async def health_check():
"""Health check endpoint."""
results = {}
results["version"] = version

# Check Telegram Bot API connectivity
try:
Expand Down
9 changes: 8 additions & 1 deletion tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ async def main(self):

try:
self.logger.info("Starting the bot")
await self.__ensure_aws_credentials()

lock = asyncio.Lock()
try:
await lock.acquire()
await self.__ensure_aws_credentials()
finally:
lock.release()

await self.application.initialize()

gas_tracker = GasTracker(application=self.application, logger=self.logger)
Expand Down

0 comments on commit 61654f8

Please sign in to comment.