Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在使用python(使用Pyvmomi)开发VMware SDK,我在所有示例或示例中都看到了这一行:
atexit.register(Disconnect, self.si)
有谁知道应该做什么?没看懂,多谢帮助。
在程序中,您可能有未捕获的异常,或者其他东西(例如保持打开的套接字),这会导致不良行为。为了解决这个问题,你可以使用atexit模块。
它允许您注册多个函数/方法以在程序结束时调用。如果对象被删除,self.disconnect()则调用。
self.disconnect()