I'm trying to upload files to S3, but if the file takes too long to upload I'd like a Timeout exception to be raised.
I've tried using the Config object from botocore to set a timeout of 1 second, but the upload process spends > 5 seconds uploading. I would expect an exception to be raised after 1 second.
import requests
from boto3 import Session
from botocore.config import Config
url = 'https://www.hq.nasa.gov/alsj/a17/A17_FlightPlan.pdf' # a large pdf
response = requests.get(url)
session = Session()
config = Config(connect_timeout=1, read_timeout=1, retries={'max_attempts': 0})
client = session.client('s3', config=config)
client.put_object(Body=response.content, Bucket='test', Key='test.pdf')
Does boto3 have a configuration option that allows me to prevent long uploads?