Botocore.exceptions.readtimeouterror: Read Timeout on Endpoint Url: "None"

Python botocore.exceptions.ReadTimeoutError() Examples

The following are 11 code examples for showing how to use botocore.exceptions.ReadTimeoutError() . These examples are extracted from open source projects. You tin can vote upward the ones you like or vote down the ones y'all don't like, and go to the original project or source file by following the links higher up each example.

You may check out the related API usage on the sidebar.

You may too want to check out all available functions/classes of the module botocore.exceptions , or effort the search function .

Example 1

def read(cocky, amt=None):         """Read at most amt bytes from the stream.          If the amt argument is omitted, read all data.         """         try:             chunk = cocky._raw_stream.read(amt)         except URLLib3ReadTimeoutError as eastward:             # 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 (non chunk and amt > 0):             # If the server sends empty contents or             # we ask to read all of the contents, and then we know             # we demand to verify the content length.             self._verify_content_length()         return chunk          

Example two

def read(cocky, amt=None):         """Read at most amt bytes from the stream.          If the amt statement 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 withal             raise ReadTimeoutError(endpoint_url=e.url, error=e)         cocky._amount_read += len(chunk)         if amt is None or (not clamper and amt > 0):             # If the server sends empty contents or             # we inquire to read all of the contents, then nosotros know             # we need to verify the content length.             self._verify_content_length()         return clamper          

Case three

def read(self, amt=None):         """Read at near amt bytes from the stream.          If the amt argument is omitted, read all data.         """         try:             clamper = self._raw_stream.read(amt)         except URLLib3ReadTimeoutError equally e:             # TODO: the url will be None as urllib3 isn't setting it yet             heighten ReadTimeoutError(endpoint_url=east.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             # nosotros ask to read all of the contents, then we know             # we need to verify the content length.             self._verify_content_length()         return chunk          

Case 4

def read(self, amt=None):         """Read at nearly amt bytes from the stream.          If the amt argument is omitted, read all information.         """         effort:             chunk = self._raw_stream.read(amt)         except URLLib3ReadTimeoutError as e:             # TODO: the url volition be None as urllib3 isn't setting it all the same             enhance ReadTimeoutError(endpoint_url=e.url, fault=e)         cocky._amount_read += len(chunk)         if amt is None or (non chunk and amt > 0):             # If the server sends empty contents or             # we enquire to read all of the contents, and then nosotros know             # nosotros need to verify the content length.             cocky._verify_content_length()         return chunk          

Case 5

def read(cocky, amt=None):         """Read at most amt bytes from the stream.          If the amt argument is omitted, read all information.         """         try:             chunk = self._raw_stream.read(amt)         except URLLib3ReadTimeoutError as eastward:             # TODO: the url will be None every bit urllib3 isn't setting it however             raise ReadTimeoutError(endpoint_url=eastward.url, fault=east)         cocky._amount_read += len(chunk)         if amt is None or (not clamper and amt > 0):             # If the server sends empty contents or             # we ask to read all of the contents, and so we know             # we demand to verify the content length.             self._verify_content_length()         render clamper          

Instance 6

def test_connector_timeout2():     session = AioSession()     config = AioConfig(max_pool_connections=1, connect_timeout=ane,                        read_timeout=one, retries={'max_attempts': 0})     async with AIOServer() equally server, \             session.create_client('s3', config=config,                                   endpoint_url=server.endpoint_url,                                   aws_secret_access_key='xxx',                                   aws_access_key_id='xxx') every bit s3_client:          with pytest.raises(ReadTimeoutError):             resp = wait s3_client.get_object(Saucepan='foo', Key='bar')             await resp["Body"].read()          

Example 7

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 \'%due south\' with schema (%southward)',                     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.Tabular array.put_item                 cocky._table.put_item(**put_item_args)                 self._cache.set(central, value, self._cache_refresh_minutes)              except (ClientError, ConnectTimeoutError, ReadTimeoutError):                 raise LookupTablesInitializationError(                     'LookupTable ({}): Failure to set key'.format(self.id)                 )          self._dirty_rows = {}          

Instance 8

def upload(cocky, bytes_data):         """         Params:             bytes_data (bytes)         """         try:             self._s3_client.Saucepan(self._s3_bucket).put_object(                 Fundamental=self._s3_key,                 Body=bytes_data             )             LOGGER.debug(                 'LookupTable (%s): Object successfully uploaded to S3',                 cocky._driver.id             )         except ClientError as err:             LOGGER.fault(                 'LookupTable (%s): Failed to upload to S3. Fault 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

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.become, 'bbbb:1')          mock_logger.assert_any_call(             'LookupTable (%s): Reading from DynamoDB timed out',             'dynamodb:table_name'         )          

Instance 10

def _load(self, key):         key_schema = self._convert_key_to_key_schema(central)          if LOGGER_DEBUG_ENABLED:             # Baby-sit json.dumps calls due to its expensive computation             LOGGER.debug(                 'LookupTable (%south): Loading cardinal \'%s\' with schema (%south)',                 self.id,                 key,                 json.dumps(key_schema)             )          attempt:             get_item_args = {                 'Primal': key_schema,                 # It's not urgently vital to do consequent reads; we accept that for some time nosotros                 # may get out-of-date reads.                 'ConsistentRead': Faux,                  # FIXME (derek.wang) This should have a ProjectionExpression to foreclose the                 #  response from returning irrelevant fields.             }              if LOGGER_DEBUG_ENABLED:                 get_item_args['ReturnConsumedCapacity'] = 'Full'              # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services             #       /dynamodb.html#DynamoDB.Table.get_item             response = cocky._table.get_item(**get_item_args)          except (ConnectTimeoutError, ReadTimeoutError):             # Catching timeouts             LOGGER.error(                 'LookupTable (%s): Reading from DynamoDB timed out',                 self.id             )             enhance LookupTablesInitializationError(                 'LookupTable ({}): Reading from DynamoDB timed out'.format(cocky.id)             )          if 'Item' not in response:             self._cache.set_blank(fundamental, self._cache_refresh_minutes)             return          if self._dynamo_db_value_key not in response['Item']:             self._cache.set_blank(primal, self._cache_refresh_minutes)             LOGGER.error(                 'LookupTable (%south): Requested value key %s seems to be missing from the table.',                 cocky.id,                 self._dynamo_db_value_key             )             return          cocky._cache.set(             key,             response['Detail'][self._dynamo_db_value_key],             self._cache_refresh_minutes         )          

Example 11

def download(cocky):         """         Render: bytes         """         effort:             start_time = time.fourth dimension()             s3_object = self._s3_client.Object(self._s3_bucket, cocky._s3_key).get()             bytes_data = s3_object.get('Body').read()              total_time = time.time() - start_time             size_kb = circular(s3_object.become('ContentLength') / 1024.0, two)             size_mb = round(size_kb / 1024.0, ii)             LOGGER.debug(                 'LookupTable (%south): Downloaded S3 file size %due south in %s seconds',                 self._driver.id,                 '{}MB'.format(size_mb) if size_mb else '{}KB'.format(size_kb),                 round(total_time, two)             )              render bytes_data         except ClientError as err:             LOGGER.error(                 'LookupTable (%s): Encountered error while downloading %southward from %south: %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):             # Communicable ConnectTimeoutError and ReadTimeoutError from botocore             LOGGER.mistake(                 'LookupTable (%south): Reading from S3 timed out',                 cocky._driver.id             )             raise LookupTablesInitializationError(                 'LookupTable ({}): Reading from S3 timed out'.format(cocky._driver.id)             )          

avilawasuld.blogspot.com

Source: https://www.programcreek.com/python/example/124280/botocore.exceptions.ReadTimeoutError

0 Response to "Botocore.exceptions.readtimeouterror: Read Timeout on Endpoint Url: "None""

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel