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 authored and caitelatte committed Nov 21, 2019
1 parent 7e10c81 commit f9d5127
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 @@ -299,12 +299,13 @@ def make_numbered_dir_with_cleanup(
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 f9d5127

Please sign in to comment.