boto3 客户端和连接
boto3 clients and connections
在 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
2ps给出了答案——不需要
在 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
2ps给出了答案——不需要