I am making an ec2 connection using boto3. I have a a lot of long running connections and most of them are going in CLOSE_WAIT state. I know after some time EC2 will close the connection at its end. Due to which connections at my end will go in 'CLOSE_WAIT' state, which will have open files i.e file descriptor. Now if the process is long running and making a lot of connections, then at one point of time it will throw 'Cannot make new connection Too many open files'. I don't want to increase the number of open file limit as it would be a temporary solution.
Is there a way by which we can close ec2 connections explicitly from boto3?