diff --git a/swh/storage/retry.py b/swh/storage/retry.py --- a/swh/storage/retry.py +++ b/swh/storage/retry.py @@ -43,6 +43,8 @@ if isinstance(error, StorageArgumentException): # Exception is due to an invalid argument return False + elif isinstance(error, KeyboardInterrupt): + return False else: # Other exception module = getattr(error, "__module__", None) diff --git a/swh/storage/tests/test_retry.py b/swh/storage/tests/test_retry.py --- a/swh/storage/tests/test_retry.py +++ b/swh/storage/tests/test_retry.py @@ -817,3 +817,21 @@ swh_storage.snapshot_add([sample_snap]) assert mock_memory.call_count == 1 + + +def test_retrying_proxy_swh_storage_keyboardinterrupt(swh_storage, sample_data, mocker): + """Unfiltered errors are raising without retry + + """ + mock_memory = mocker.patch("swh.storage.in_memory.InMemoryStorage.content_add") + mock_memory.side_effect = KeyboardInterrupt() + + sample_content = sample_data.content + + content = swh_storage.content_get_data(sample_content.sha1) + assert content is None + + with pytest.raises(KeyboardInterrupt): + swh_storage.content_add([sample_content]) + + assert mock_memory.call_count == 1