Python botocore.exceptions.ReadTimeoutError() Examples
The following are 11
code examples of botocore.exceptions.ReadTimeoutError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.exceptions
, or try the search function
.
Example #1
Source File: response.py From deepWordBug with Apache License 2.0 | 6 votes |
def read(self, amt=None): """Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ try: chunk = self._raw_stream.read(amt) except URLLib3ReadTimeoutError as e: # TODO: the url will be None as urllib3 isn't setting it yet raise ReadTimeoutError(endpoint_url=e.url, error=e) self._amount_read += len(chunk) if amt is None or (not chunk and amt > 0): # If the server sends empty contents or # we ask to read all of the contents, then we know # we need to verify the content length. self._verify_content_length() return chunk
Example #2
Source File: response.py From bash-lambda-layer with MIT License | 6 votes |
def read(self, amt=None): """Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ try: chunk = self._raw_stream.read(amt) except URLLib3ReadTimeoutError as e: # TODO: the url will be None as urllib3 isn't setting it yet raise ReadTimeoutError(endpoint_url=e.url, error=e) self._amount_read += len(chunk) if amt is None or (not chunk and amt > 0): # If the server sends empty contents or # we ask to read all of the contents, then we know # we need to verify the content length. self._verify_content_length() return chunk
Example #3
Source File: response.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def read(self, amt=None): """Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ try: chunk = self._raw_stream.read(amt) except URLLib3ReadTimeoutError as e: # TODO: the url will be None as urllib3 isn't setting it yet raise ReadTimeoutError(endpoint_url=e.url, error=e) self._amount_read += len(chunk) if amt is None or (not chunk and amt > 0): # If the server sends empty contents or # we ask to read all of the contents, then we know # we need to verify the content length. self._verify_content_length() return chunk
Example #4
Source File: response.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def read(self, amt=None): """Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ try: chunk = self._raw_stream.read(amt) except URLLib3ReadTimeoutError as e: # TODO: the url will be None as urllib3 isn't setting it yet raise ReadTimeoutError(endpoint_url=e.url, error=e) self._amount_read += len(chunk) if amt is None or (not chunk and amt > 0): # If the server sends empty contents or # we ask to read all of the contents, then we know # we need to verify the content length. self._verify_content_length() return chunk
Example #5
Source File: response.py From aws-builders-fair-projects with Apache License 2.0 | 6 votes |
def read(self, amt=None): """Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ try: chunk = self._raw_stream.read(amt) except URLLib3ReadTimeoutError as e: # TODO: the url will be None as urllib3 isn't setting it yet raise ReadTimeoutError(endpoint_url=e.url, error=e) self._amount_read += len(chunk) if amt is None or (not chunk and amt > 0): # If the server sends empty contents or # we ask to read all of the contents, then we know # we need to verify the content length. self._verify_content_length() return chunk
Example #6
Source File: test_config.py From aiobotocore with Apache License 2.0 | 5 votes |
def test_connector_timeout2(): session = AioSession() config = AioConfig(max_pool_connections=1, connect_timeout=1, read_timeout=1, retries={'max_attempts': 0}) async with AIOServer() as server, \ session.create_client('s3', config=config, endpoint_url=server.endpoint_url, aws_secret_access_key='xxx', aws_access_key_id='xxx') as s3_client: with pytest.raises(ReadTimeoutError): resp = await s3_client.get_object(Bucket='foo', Key='bar') await resp["Body"].read()
Example #7
Source File: driver_dynamodb.py From streamalert with Apache License 2.0 | 5 votes |
def commit(self): for key, value in self._dirty_rows.items(): key_schema = self._convert_key_to_key_schema(key) if LOGGER_DEBUG_ENABLED: # Guard json.dumps calls due to its expensive computation LOGGER.debug( 'LookupTable (%s): Updating key \'%s\' with schema (%s)', self.id, key, json.dumps(key_schema) ) try: item = key_schema item[self._dynamo_db_value_key] = value put_item_args = { 'Item': item, } if LOGGER_DEBUG_ENABLED: put_item_args['ReturnConsumedCapacity'] = 'TOTAL' # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services # /dynamodb.html#DynamoDB.Table.put_item self._table.put_item(**put_item_args) self._cache.set(key, value, self._cache_refresh_minutes) except (ClientError, ConnectTimeoutError, ReadTimeoutError): raise LookupTablesInitializationError( 'LookupTable ({}): Failure to set key'.format(self.id) ) self._dirty_rows = {}
Example #8
Source File: driver_s3.py From streamalert with Apache License 2.0 | 5 votes |
def upload(self, bytes_data): """ Params: bytes_data (bytes) """ try: self._s3_client.Bucket(self._s3_bucket).put_object( Key=self._s3_key, Body=bytes_data ) LOGGER.debug( 'LookupTable (%s): Object successfully uploaded to S3', self._driver.id ) except ClientError as err: LOGGER.error( 'LookupTable (%s): Failed to upload to S3. Error message: %s', self._driver.id, err.response['Error']['Message'] ) raise LookupTablesCommitError( 'LookupTable S3 Driver Failed with Message: {}'.format( err.response['Error']['Message'] ) ) except (ConnectTimeoutError, ReadTimeoutError): # Catching ConnectTimeoutError and ReadTimeoutError from botocore LOGGER.error( 'LookupTable (%s): Reading from S3 timed out', self._driver.id ) raise LookupTablesCommitError( 'LookupTable ({}): Reading from S3 timed out'.format(self._driver.id) )
Example #9
Source File: test_driver_dynamodb.py From streamalert with Apache License 2.0 | 5 votes |
def test_botocore_read_timeout(self, mock_logger, boto_resource_fn_mock): """LookupTables - Drivers - DynamoDB Driver - Get - ReadTimeoutError""" boto_resource_fn_mock.return_value.Table.return_value.get_item.side_effect = \ ReadTimeoutError( 'TestPool', 'Test Read timed out.', endpoint_url='test/url' ) self._driver.initialize() assert_raises(LookupTablesInitializationError, self._driver.get, 'bbbb:1') mock_logger.assert_any_call( 'LookupTable (%s): Reading from DynamoDB timed out', 'dynamodb:table_name' )
Example #10
Source File: driver_dynamodb.py From streamalert with Apache License 2.0 | 4 votes |
def _load(self, key): key_schema = self._convert_key_to_key_schema(key) if LOGGER_DEBUG_ENABLED: # Guard json.dumps calls due to its expensive computation LOGGER.debug( 'LookupTable (%s): Loading key \'%s\' with schema (%s)', self.id, key, json.dumps(key_schema) ) try: get_item_args = { 'Key': key_schema, # It's not urgently vital to do consistent reads; we accept that for some time we # may get out-of-date reads. 'ConsistentRead': False, # FIXME (derek.wang) This should have a ProjectionExpression to prevent the # response from returning irrelevant fields. } if LOGGER_DEBUG_ENABLED: get_item_args['ReturnConsumedCapacity'] = 'TOTAL' # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services # /dynamodb.html#DynamoDB.Table.get_item response = self._table.get_item(**get_item_args) except (ConnectTimeoutError, ReadTimeoutError): # Catching timeouts LOGGER.error( 'LookupTable (%s): Reading from DynamoDB timed out', self.id ) raise LookupTablesInitializationError( 'LookupTable ({}): Reading from DynamoDB timed out'.format(self.id) ) if 'Item' not in response: self._cache.set_blank(key, self._cache_refresh_minutes) return if self._dynamo_db_value_key not in response['Item']: self._cache.set_blank(key, self._cache_refresh_minutes) LOGGER.error( 'LookupTable (%s): Requested value key %s seems to be missing from the table.', self.id, self._dynamo_db_value_key ) return self._cache.set( key, response['Item'][self._dynamo_db_value_key], self._cache_refresh_minutes )
Example #11
Source File: driver_s3.py From streamalert with Apache License 2.0 | 4 votes |
def download(self): """ Return: bytes """ try: start_time = time.time() s3_object = self._s3_client.Object(self._s3_bucket, self._s3_key).get() bytes_data = s3_object.get('Body').read() total_time = time.time() - start_time size_kb = round(s3_object.get('ContentLength') / 1024.0, 2) size_mb = round(size_kb / 1024.0, 2) LOGGER.debug( 'LookupTable (%s): Downloaded S3 file size %s in %s seconds', self._driver.id, '{}MB'.format(size_mb) if size_mb else '{}KB'.format(size_kb), round(total_time, 2) ) return bytes_data except ClientError as err: LOGGER.error( 'LookupTable (%s): Encountered error while downloading %s from %s: %s', self._driver.id, self._s3_key, self._s3_bucket, err.response['Error']['Message'] ) raise LookupTablesInitializationError( 'LookupTable S3 Driver Failed with Message: {}'.format( err.response['Error']['Message'] ) ) except (ConnectTimeoutError, ReadTimeoutError): # Catching ConnectTimeoutError and ReadTimeoutError from botocore LOGGER.error( 'LookupTable (%s): Reading from S3 timed out', self._driver.id ) raise LookupTablesInitializationError( 'LookupTable ({}): Reading from S3 timed out'.format(self._driver.id) )