-
Notifications
You must be signed in to change notification settings - Fork 451
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
Process manager should not attempt to unlink the processes database file in case of OperationalError #7932
Merged
kozlovsky
merged 1 commit into
Tribler:release/7.13
from
kozlovsky:fix/process_manager_connect_permission_error
Mar 19, 2024
Merged
Process manager should not attempt to unlink the processes database file in case of OperationalError #7932
kozlovsky
merged 1 commit into
Tribler:release/7.13
from
kozlovsky:fix/process_manager_connect_permission_error
Mar 19, 2024
Conversation
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
kozlovsky
force-pushed
the
fix/process_manager_connect_permission_error
branch
2 times, most recently
from
March 18, 2024 12:44
f34d807
to
06f49d5
Compare
kozlovsky
force-pushed
the
fix/process_manager_connect_permission_error
branch
from
March 18, 2024 16:03
06f49d5
to
89bee0d
Compare
kozlovsky
requested review from
a team and
drew2a
and removed request for
a team
March 19, 2024 10:57
drew2a
approved these changes
Mar 19, 2024
Comment on lines
304
to
314
class TestError(Exception): | ||
pass | ||
|
||
|
||
@patch('sqlite3.connect', MagicMock(side_effect=sqlite3.DatabaseError('error text'))) | ||
@patch('pathlib.Path.unlink', MagicMock(side_effect=TestError)) | ||
def test_connect_database_error_raise_non_permission_error(process_manager): | ||
# All OperationalError exceptions except "unable to open database file" should be re-raised | ||
with pytest.raises(TestError): | ||
with process_manager.connect(): | ||
pass # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: The TestError
class could be defined inside the test_connect_database_error_raise_non_permission_error
function since it's only used there. This will increase the readability of the entire test file.
Suggested change
class TestError(Exception): | |
pass | |
@patch('sqlite3.connect', MagicMock(side_effect=sqlite3.DatabaseError('error text'))) | |
@patch('pathlib.Path.unlink', MagicMock(side_effect=TestError)) | |
def test_connect_database_error_raise_non_permission_error(process_manager): | |
# All OperationalError exceptions except "unable to open database file" should be re-raised | |
with pytest.raises(TestError): | |
with process_manager.connect(): | |
pass # pragma: no cover | |
@patch('sqlite3.connect', MagicMock(side_effect=sqlite3.DatabaseError('error text'))) | |
@patch('pathlib.Path.unlink', MagicMock(side_effect=TestError)) | |
def test_connect_database_error_raise_non_permission_error(process_manager): | |
class TestError(Exception): | |
pass | |
# All OperationalError exceptions except "unable to open database file" should be re-raised | |
with pytest.raises(TestError): | |
with process_manager.connect(): | |
pass # pragma: no cover |
kozlovsky
force-pushed
the
fix/process_manager_connect_permission_error
branch
from
March 19, 2024 11:55
89bee0d
to
5d6bf31
Compare
…ile in case of OperationalError
kozlovsky
force-pushed
the
fix/process_manager_connect_permission_error
branch
from
March 19, 2024 12:53
5d6bf31
to
c87dfbc
Compare
This was referenced Mar 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #7931 by handling all
OperationalError
exceptions beforeDatabaseError
exceptions, and by suppressing possiblePermissionError
exceptions when trying to remove the database filw after theDatabaseError