Skip to content

Commit

Permalink
Avoid uncaught exception if __process_nearby_mons fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Grennith committed Apr 16, 2023
1 parent 5fda46d commit 27e07a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
configs/addresses.json
gym_info.json
temp/*
plugins/*
Expand Down
1 change: 0 additions & 1 deletion mapadroid/db/PooledQueryExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async def _init_pool(self):
else:
db_uri: str = f"mysql+aiomysql://{self.user}:{self.password}@{self.host}:{self.port}/{self.database}"


logger.info("Connecting to DB")
self._db_accessor: DbAccessor = DbAccessor(db_uri, self._poolsize)
await self._db_accessor.setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ async def __process_lure_no_iv(self, data, received_timestamp) -> Tuple[List[int

async def __process_nearby_mons(self, data, received_timestamp) -> Tuple[List[int], List[int], int]:
nearby_mons_time_start = self.get_time_ms()
cell_encounters: List[int] = []
stop_encounters: List[int] = []
async with self.__db_wrapper as session, session:
try:
cell_encounters, stop_encounters = await self.__db_submit.mons_nearby(session, received_timestamp,
Expand All @@ -283,6 +285,7 @@ async def __process_nearby_mons(self, data, received_timestamp) -> Tuple[List[in

async def __process_wild_mons(self, data, received_timestamp) -> Tuple[List[int], int]:
mons_time_start = self.get_time_ms()
encounter_ids_in_gmo: List[int] = []
async with self.__db_wrapper as session, session:
try:
encounter_ids_in_gmo = await self.__db_submit.mons(session,
Expand All @@ -291,7 +294,6 @@ async def __process_wild_mons(self, data, received_timestamp) -> Tuple[List[int]
await session.commit()
except Exception as e:
logger.warning("Failed submitting wild mons: {}", e)
encounter_ids_in_gmo = []
mons_time = self.get_time_ms() - mons_time_start
return encounter_ids_in_gmo, mons_time

Expand Down

0 comments on commit 27e07a0

Please sign in to comment.