I want the minio-client to throw an error if a connection error occurs while putting data to the minio-server. It correctly returns an error when setting up a connection and the server is down. But if I disconnect the network while uploading (putting). The python process will stay open 'forever'.
What I want is that it returns an error after for example a timeout of 60 seconds. I just can't find anything like it in any documentation.
My (working) code simplified:
from minio import Minio
client = None
bucket = 'testbucket'
def connect():
print(f"Creating MinioClient")
global client
client = Minio(
'10.0.0.1:9000',
access_key='myaccesskey',
secret_key='mysecretkey',
secure=False
)
def createBucket():
global client
global bucket
print(f"Making bucket '{bucket}' if not exists")
found = client.bucket_exists(bucket)
if not found:
client.make_bucket(bucket)
else:
print(f"Bucket '{bucket}' already exists")
def putFile():
""" Upload data """
print("Uploading the file with fput")
global client
global bucket
objectname = 'ReallyBigFile'
filepath = '/home/jake/4GBfile.bin'
try:
result = client.fput_object(
bucket,
objectname,
filepath,
)
except IOError as err:
print(err)
print("Created {0} object; etag: {1}, version-id: {2}".format(result.object_name, result.etag, result.version_id))
connect()
createBucket()
putFile()
Anybody an idea how I can force minio to exit fputting on a connection-error?
Already tried setting up the connection like this: No success:
client = Minio(
'10.0.0.1:9000',
access_key='myaccesskey',
secret_key='mysecretkey',
secure=False,
http_client=urllib3.poolmanager.PoolManager(
timeout=1,
retries=urllib3.Retry(
total=3,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)
Some research showed that Minio in fact is capable of recognizing a connection loss while uploading. It turns out it really has to do with the python client or my implementation of it.
Test with the command line tool mc:
The first session is a stable connection and the second is disconnected during upload.