Skip to content

Commit

Permalink
Register cleanup_numbered_dir for atexit before the cleanup for locks…
Browse files Browse the repository at this point in the history
… is registered (pytest-dev#1120)

The cleanup of the numbered directory will now be executed after
the locks of the current process got removed.
  • Loading branch information
bitmuster committed Jul 17, 2019
1 parent 157515f commit 2b2f79f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,13 @@ def make_numbered_dir_with_cleanup(root, prefix, keep, lock_timeout):
for i in range(10):
try:
p = make_numbered_dir(root, prefix)
consider_lock_dead_if_created_before = p.stat().st_mtime - lock_timeout
lock_path = create_cleanup_lock(p)
atexit.register(cleanup_numbered_dir, root, prefix, keep, consider_lock_dead_if_created_before)
register_cleanup_lock_removal(lock_path)
except Exception as exc:
e = exc
else:
consider_lock_dead_if_created_before = p.stat().st_mtime - lock_timeout
cleanup_numbered_dir(
root=root,
prefix=prefix,
Expand Down

0 comments on commit 2b2f79f

Please sign in to comment.