microsoft-authentication-library-for-python
microsoft-authentication-library-for-python copied to clipboard
Add close method to app
Fixes Issue #370 Session/socket never closed, warnings shown
The msal application does not close it's resources like eg: self.http_client. As a result a 'ResourceWarning unclosed <ssl.SSLSocket' is shown when the app goes out of scope (when warnings are enabled)
This fix adds and explicit close method so developpers can cleanly close the app if they so desire.
A better fix might be needed. A close() method does not help in case of __init__ errors. For example when you provide a wrong tenant_id
try:
app = msal.application.ConfidentialClientApplication(APPID, client_credential=SECRET,
authority="https://login.microsoftonline.com/" + FAULTY_TENANT)
except Exception:
app.close() -> fails because app is not defined....
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
:x: HansWeltar sign now
You have signed the CLA already but the status is still pending? Let us recheck it.
adressed
A better fix might be needed. A close() method does not help in case of init errors. For example when you provide a wrong tenant_id
try: app = msal.application.ConfidentialClientApplication(APPID, client_credential=SECRET, authority="https://login.microsoftonline.com/" + FAULTY_TENANT) except Exception: app.close() -> fails because app is not defined....
Seems like the original issue still exists? Is this PR valid?