Skip to content

test: add coverage for thread safety decorator (threading_utils.py) #1170

Description

@mnadzam

src/fromager/threading_utils.py has no dedicated unit tests file. with_thread_lock() is a decorator factory that provides per-function locking. It guards:

  • _get_hooks() in hooks.py -- hook manager caching
  • update_wheel_mirror() in server.py -- file system operations during parallel builds

Broken locking produces intermittent race conditions that are extremely hard to diagnose in production.

Note: Other threading primitives exist in the codebase (threading.Lock() in dependency_graph.py, threading.Thread in server.py), but with_thread_lock() is the only reusable decorator-based synchronization mechanism.

Scope

Function Lines Callers
with_thread_lock() 8-27 2 files

Acceptance Criteria

  • Test that the decorated function acquires a lock
  • Test mutual exclusion with concurrent threads
  • Test that different decorated functions get independent locks
  • Test reentrance behavior

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions