-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle error message during storage backend init better
- Loading branch information
1 parent
ca17924
commit 54f8fe3
Showing
3 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Test container initialization.""" | ||
import psutil, os | ||
|
||
def test_file_descriptor_closed(aiida_profile): | ||
"""Checks if the number of open file descriptors change during a reset.""" | ||
def list_open_file_descriptors(): | ||
process = psutil.Process(os.getpid()) | ||
return process.open_files() | ||
# We have some connections active due to aiida profile during the first | ||
# reset these are destroyed. We check the second time changes the number of | ||
# open file descriptors. | ||
# TODO The fix should keep the existing connections alive and just reuse them | ||
# then one does not need to do two resets. | ||
aiida_profile.reset_storage() | ||
open_file_descriptors_before = list_open_file_descriptors() | ||
aiida_profile.reset_storage() | ||
open_file_descriptors_after = list_open_file_descriptors() | ||
assert len(open_file_descriptors_before) == len(open_file_descriptors_after), f"Before these file descriptor were open:\n{open_file_descriptors_before}\n Now these are open:\n{open_file_descriptors_after}" |