Exchangelib 关闭连接
Exchangelib close connection
我想知道是否有办法关闭与 exchangelib 的连接。
这是我的设置和连接函数;我需要定义一个 close_conection()
函数,但没有找到任何阅读文档。
class Exchange:
def __init__(self, username, password, server):
""""""
self.username = username
self.password = password
self.server = server
def account(self):
"""Setup and connecting"""
creds = Credentials(
username=self.username,
password=self.password
)
config = Configuration(server=self.server, credentials=creds)
account = Account(
primary_smtp_address=self.username,
autodiscover=False,
config=config,
access_type=DELEGATE
)
return account
exchangelib 将在垃圾回收时关闭 TCP 连接。参见 https://github.com/ecederstrand/exchangelib/blob/3c10bc7ad0e0ba2aa0b4a55eb95d234ff8c6091a/exchangelib/protocol.py#L114
您还可以通过以下方式显式关闭连接:account.protocol.close()
我想知道是否有办法关闭与 exchangelib 的连接。
这是我的设置和连接函数;我需要定义一个 close_conection()
函数,但没有找到任何阅读文档。
class Exchange:
def __init__(self, username, password, server):
""""""
self.username = username
self.password = password
self.server = server
def account(self):
"""Setup and connecting"""
creds = Credentials(
username=self.username,
password=self.password
)
config = Configuration(server=self.server, credentials=creds)
account = Account(
primary_smtp_address=self.username,
autodiscover=False,
config=config,
access_type=DELEGATE
)
return account
exchangelib 将在垃圾回收时关闭 TCP 连接。参见 https://github.com/ecederstrand/exchangelib/blob/3c10bc7ad0e0ba2aa0b4a55eb95d234ff8c6091a/exchangelib/protocol.py#L114
您还可以通过以下方式显式关闭连接:account.protocol.close()