Skip to content

Commit 89a3996

Browse files
committed
Refactor logs during recent debug effort
1 parent 26240cb commit 89a3996

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

msal_extensions/cache_lock.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def _try_to_create_lock_file(self):
4343
check_interval = 0.25
4444
current_time = getattr(time, "monotonic", time.time)
4545
timeout_end = current_time() + timeout
46+
pid = os.getpid()
4647
while timeout_end > current_time():
4748
try:
4849
with open(self._lockpath, 'x'): # pylint: disable=unspecified-encoding
@@ -51,15 +52,18 @@ def _try_to_create_lock_file(self):
5152
logger.warning("Python 2 does not support atomic creation of file")
5253
return False
5354
except FileExistsError: # Only Python 3 will reach this clause
54-
logger.warning("Lock file exists, trying again after some time")
55+
logger.debug(
56+
"Process %d found existing lock file, will retry after %f second",
57+
pid, check_interval)
5558
time.sleep(check_interval)
5659
return False
5760

5861
def __enter__(self):
62+
pid = os.getpid()
5963
if not self._try_to_create_lock_file():
60-
logger.warning("Failed to create lock file")
64+
logger.warning("Process %d failed to create lock file", pid)
6165
file_handle = self._lock.__enter__()
62-
file_handle.write('{} {}'.format(os.getpid(), sys.argv[0]).encode('utf-8'))
66+
file_handle.write('{} {}'.format(pid, sys.argv[0]).encode('utf-8'))
6367
return file_handle
6468

6569
def __exit__(self, *args):

0 commit comments

Comments
 (0)