我想知道有没有办法切断和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发布于 2019-11-07 16:28:09
exchangelib将在垃圾回收时关闭TCP连接。请参阅https://github.com/ecederstrand/exchangelib/blob/3c10bc7ad0e0ba2aa0b4a55eb95d234ff8c6091a/exchangelib/protocol.py#L114
您还可以使用以下命令显式关闭连接:account.protocol.close()
https://stackoverflow.com/questions/58732311
复制相似问题