Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29250

Too many open files while getting images from the S3 bucket

$
0
0

I am using boto3 to get the image content from the s3. Using the following function.

def read_image_from_s3(bucket, key):
    s3 = boto3.resource('s3')
    bucket = s3.Bucket(bucket)
    object = bucket.Object(key)
    response = object.get()
    file_stream = response['Body']
    content = file_stream.read()
    return content

and I am running this code on each image I have almost 21k images in the bucket. And I am getting error as

Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 324, in _invoke_callbacks
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 75, in wrapped
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 425, in result
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 67, in _get_authorization_headers
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/auth/credentials.py", line 124, in before_request
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/oauth2/service_account.py", line 334, in refresh
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/oauth2/_client.py", line 153, in jwt_grant
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/oauth2/_client.py", line 105, in _token_endpoint_request
  File "/home/ubuntu/.local/lib/python3.6/site-packages/google/auth/transport/requests.py", line 169, in __call__
  File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
  File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
  File "/home/ubuntu/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/connection.py", line 394, in connect
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 336, in ssl_wrap_socket
  File "/home/ubuntu/.local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 453, in load_verify_locations
  File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 777, in load_verify_locations
  File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
OpenSSL.SSL.Error: [('system library', 'fopen', 'Too many open files'), ('BIO routines', 'BIO_new_file', 'system lib'), ('x509 certificate routines', 'X509_load_cert_crl_file', 'system lib')]

I also put time sleep of 5 secs. But still, this error persists.


Viewing all articles
Browse latest Browse all 29250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>