截止博托EC2连接 [英] Closing boto ec2 connection

查看:211
本文介绍了截止博托EC2连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何关闭博托EC2连接?

How to close a boto ec2 connection?

我打开使用连接:

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

我试过的close()函数,但我不认为它拆掉连接。

I tried the close() function but I don't think it tears down the connection.

conn.close()

输出上运行的close(): [调试]:关闭所有的HTTP连接

即使在关闭后,它得到所有的预约

Even after closing, it gets all the reservation

reservations = conn.get_all_instances()

我是看着这些文档 http://boto.readthedocs.org/en/最新/ ec2_tut.html 但无法找到的close()函数的文档。

I was looking at these doc http://boto.readthedocs.org/en/latest/ec2_tut.html but couldn't find the documentation for close() function.

我真的AP preciate如果有人能帮助我在这里。

I would really appreciate if someone can help me out here.

感谢

推荐答案

博托管理HTTP连接池,并尝试重新使用它们,以节省连接费用(尤其是HTTPS握手)。使用关闭方法确实允许垃圾回收的连接,但是当你试图在同一EC2Connection另一个请求对象的一个​​新的连接将会为你创造这就是为什么一旦该后续请求仍然有效。

Boto manages a pool of HTTP connections and attempts to reuse them to save on connection costs (especially the HTTPS handshake). Using the close method does allow the connection to be garbage collected but as soon as you attempt another request on the same EC2Connection object a new connection will be created for you which is why the subsequent request still works.

要加入到这一点,我想我的建议是不要过分担心关闭连接,因为博托试图pretty的难以有效地管理这些连接和重用他们在可能的情况。

To add to this, I guess my advise would be not to worry too much about closing connections because boto is trying pretty hard to manage those connections efficiently and reuse them when possible.

您遇到了具体问题WRT打开连接?

Are you running into specific issues wrt to open connections?

这篇关于截止博托EC2连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆