Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: force sftp cleanup when done with instance #5698

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def _client(
yield instance
test_failed = request.session.testsfailed - previous_failures > 0
_collect_artifacts(instance, request.node.nodeid, test_failed)
# conflicting requirements:
# - pytest thinks that it can cleanup loggers after tests run
# - pycloudlib thinks that at garbage collection is a good place to tear
# down sftp connections
# After the final test runs, pytest might clean up loggers which will cause
# paramiko to barf when it logs that the connection is being closed.
#
# Manually run __del__() to prevent this teardown mess.
instance.instance.__del__()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: del instance.instance

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: del instance.instance

fyi that's what the original implementation attempted, but it didn't work because del decrements the refcount, which will not necessarily cause the refcount to go to 0, nor will it force the garbage collector to run (which is what invokes __del__()). This really deserved a comment, but since this is somehow happening in CI still, further investigation is required



@pytest.fixture
Expand Down