chore: log on file lock

This commit is contained in:
张泊明518370910136 2024-10-17 22:57:09 -04:00
parent 80770873aa
commit 95014dfcde
GPG Key ID: CA088E6D9284F870

View File

@ -253,8 +253,12 @@ def joj3_scoreboard(
lock_file_path = os.path.join( lock_file_path = os.path.join(
settings.repos_dir, repo_name, settings.joj3_lock_file_path settings.repos_dir, repo_name, settings.joj3_lock_file_path
) )
lock = FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout) logger.info(
with lock.acquire(): f"try to acquire lock, file path: {lock_file_path}, "
+ f"timeout: {settings.joj3_lock_file_timeout}"
)
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
logger.info("file lock acquired")
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading") repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
repo: Repo = tea.pot.git.get_repo(repo_name) repo: Repo = tea.pot.git.get_repo(repo_name)
if "grading" not in repo.remote().refs: if "grading" not in repo.remote().refs:
@ -329,8 +333,12 @@ def joj3_failed_table(
lock_file_path = os.path.join( lock_file_path = os.path.join(
settings.repos_dir, repo_name, settings.joj3_lock_file_path settings.repos_dir, repo_name, settings.joj3_lock_file_path
) )
lock = FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout) logger.info(
with lock.acquire(): f"try to acquire lock, file path: {lock_file_path}, "
+ f"timeout: {settings.joj3_lock_file_timeout}"
)
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
logger.info("file lock acquired")
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading") repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
repo: Repo = tea.pot.git.get_repo(repo_name) repo: Repo = tea.pot.git.get_repo(repo_name)
if "grading" not in repo.remote().refs: if "grading" not in repo.remote().refs: