2017-02-02 225 views
1

在boto2中,您可以在完成客戶端後關閉()連接。你如何實現與boto3boto3客戶端和連接

同樣我希望有一個DAO對象taht看起來是這樣的:

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 
+0

我猜一個更好的問題要問 - 這是甚至需要嗎?我在網上搜索,找不到有人問這個問題。 – user1836155

+1

不需要:https://github.com/boto/botocore/issues/619 – 2ps

回答