Closing boto ec2 connection

How to close the boto ec2 connection?

I opened a connection using:

conn = boto.ec2.connect_to_region(region, aws_access_key_id=access_key, aws_secret_access_key=secret_key)    

      

I tried the close () function, but I don't think it breaks the connection.

conn.close()

      

Exit when running close (): [DEBUG]:closing all HTTP connections

Even after closing, he gets all the reservations

reservations = conn.get_all_instances()

      

I've looked at these docs http://boto.readthedocs.org/en/latest/ec2_tut.html but couldn't find any documentation for the close () function.

I would really appreciate if someone can help me here.

thank

+3


source to share


1 answer


Boto manages a pool of HTTP connections and tries to reuse them to save on connection costs (especially the HTTPS handshake). Using the method close

allows garbage collection, but as soon as you try to execute another request on the same EC2Connection object, a new connection will be created for you, so the subsequent request still works.

To add to that, I think my advice would not be too worried about closing connections, because boto tries to manage those connections fairly efficiently and efficiently and reuse them whenever possible.



Are you running specific wrt problems to open connections?

+3


source







All Articles