Skip to content

Commit 7cb11cb

Browse files
committed
CancelledError fix Ctrl C
1 parent 7da59ad commit 7cb11cb

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

aws-cli-main.py

Whitespace-only changes.

aws-cli-mainII.py

Whitespace-only changes.

awscli/botocore/httpsession.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
)
2929
from urllib3.util.url import parse_url
3030

31+
from concurrent.futures import CancelledError
32+
3133
try:
3234
from urllib3.util.ssl_ import OP_NO_TICKET, PROTOCOL_TLS_CLIENT
3335
except ImportError:
@@ -497,6 +499,8 @@ def send(self, request):
497499
raise ConnectionClosedError(
498500
error=e, request=request, endpoint_url=request.url
499501
)
502+
except CancelledError:
503+
raise
500504
except Exception as e:
501505
message = 'Exception received when sending urllib3 HTTP request'
502506
logger.debug(message, exc_info=True)

tests/unit/botocore/test_http_session.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
mask_proxy_url,
1919
)
2020
from urllib3.exceptions import NewConnectionError, ProtocolError, ProxyError
21+
from concurrent.futures import CancelledError
2122

2223
from tests import mock, unittest
2324

@@ -463,6 +464,12 @@ def test_catches_bad_status_line(self):
463464
with pytest.raises(ConnectionClosedError):
464465
self.make_request_with_error(error)
465466

467+
def test_catches_cancelled_error(self):
468+
self.connection.urlopen.side_effect = CancelledError()
469+
session = URLLib3Session()
470+
with pytest.raises(CancelledError):
471+
session.send(self.request.prepare())
472+
466473
def test_catches_proxy_error(self):
467474
self.connection.urlopen.side_effect = ProxyError('test', None)
468475
session = URLLib3Session(

0 commit comments

Comments
 (0)