Skip to content

Tree: close temporary tar files used by copy and rcopy#681

Open
thiell wants to merge 1 commit into
clustershell:masterfrom
thiell:fix/tree-close-tmptar
Open

Tree: close temporary tar files used by copy and rcopy#681
thiell wants to merge 1 commit into
clustershell:masterfrom
thiell:fix/tree-close-tmptar

Conversation

@thiell

@thiell thiell commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

TreeWorker never closes its temporary tar files: one per forward copy worker, one per rcopy source node. Their file descriptors stay open until the file objects are garbage-collected, which is deferred by reference cycles — and for a timed-out rcopy node cannot happen before the worker object itself is released. This means ResourceWarning: unclosed file noise in warning-enabled runs and open-fd accumulation in long-running processes embedding the library. Found while writing the tree copy tests for #680.

  • copy: wrap the temporary tar file in a with block in _launch()
  • rcopy: close the per-node temporary tar file in _on_remote_node_close()TarFile.close() does not close a caller-provided fileobj
  • rcopy: close leftover tar files of timed-out nodes at worker completion in _check_fini(), and drop data arriving after a node's terminal event (the gateway's final grooming flush follows its TimeoutMessage), so the cleanup is final
  • add regression tests for these paths (fail before the fix, pass after)

Signed-off-by: Stephane Thiell <stephane@thiell.com>
@thiell thiell added this to the 1.11 milestone Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant