在boto2中,您可以在完成客户端后关闭()连接。你如何用boto3
实现同样的目标我想要一个DAO对象,看起来像这样:
class MyDAO:
def __init__(self, mat_set, region):
self.client = boto3.client('ec2' ... )
def __enter__(self):
return self
def __exit__(self, type_, value, traceback):
## Clean up the connection of the client
def f():
with MyDAO() as dao:
## Do some stuff