Skip to content

Commit

Permalink
Add logging for account handler assigning
Browse files Browse the repository at this point in the history
  • Loading branch information
Grennith committed Feb 20, 2024
1 parent 11766b9 commit ca49d47
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mapadroid/account_handler/AccountHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ def __init__(self, db_wrapper: DbWrapper):
async def get_account(self, device_id: int, purpose: AccountPurpose,
location_to_scan: Optional[Location],
including_google: bool = True) -> Optional[SettingsPogoauth]:
logger.info("Device {} is requesting an account for {}", device_id, purpose)
async with self._assignment_lock:
# First, fetch all pogoauth accounts
logger.debug("Lock acquired for {} to query database", device_id)
async with self._db_wrapper as session, session:
device_entry: Optional[SettingsDevice] = await SettingsDeviceHelper.get(session,
self._db_wrapper.get_instance_id(),
Expand Down Expand Up @@ -98,6 +100,8 @@ async def get_account(self, device_id: int, purpose: AccountPurpose,
# Expunge is needed to not automatically have attempts to refresh values outside a DB session
session.expunge(login_to_use)
await session.commit()
logger.info("Found account {} ({}) to be used for device {}",
login_to_use.account_id, login_to_use.username, device_id)
return login_to_use
# TODO: try/except

Expand Down

0 comments on commit ca49d47

Please sign in to comment.