Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make portalocker optional #117

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Make portalocker optional #117

merged 1 commit into from
Jan 30, 2025

Conversation

rayluo
Copy link
Contributor

@rayluo rayluo commented Oct 20, 2022

This is currently an experimental PR. It will not be merged, not until we receive some test feedback. To beta test this PR, you will need to pull it from its feature branch.

Usage: There is no API change. MSAL EX will automatically utilize portalocker when portalocker is available in current environment, and switch to a new portalocker-less implementation otherwise.

Note:

  • A lock mechanism is only used to guard against garbled data due to concurrent read/write. A lock mechanism in itself does not make the higher level application more or less performant. When your app is overloaded, previously (i.e. before this PR) you will see portalocker.exceptions.LockException which means the locking mechanism is doing its job. After this PR, under the same heavy load, you will see LockError instead, which also means the new lock mechanism is functioning.
  • Test automation currently fails, because keyring daemon no longer works. It used to work even in headless test environment. We will look into it at a later time. But this should not affect or block the beta testing of this PR.
  • UPDATE on Dec 2024: This PR has been used internally for 2+ years without any issue. Thanks @bebound for testing!

CC: @jiasli

@rayluo rayluo force-pushed the optional-portalocker branch 5 times, most recently from 7ac2952 to 323ac39 Compare October 20, 2022 07:20
"""It will be raised when unable to obtain a lock"""


class CrossPlatLock(object):
Copy link
Contributor

@jiasli jiasli Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, Azure CLI doesn't really need such a complex lock at the comment. Previously ADAL didn't have locking mechanism and worked mostly fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. But if the current PR's non-portalocker lock is harmless, then we might as well just use it.

We are open to the dummy lock idea, too. We may work on it at a later time. It can be done, but it is more work, in terms of needing to expand the current MSAL EX api to allow a "no lock" option. (The current file-based lock, on the contrary, is a drop-in replacement for portalocker, and keeps the MSAL EX api intact.)

If the file-based lock does not work well for Azure CLI on SAW, we will prioritize the dummy lock work accordingly.

@rayluo
Copy link
Contributor Author

rayluo commented Nov 26, 2024

See this comment on how to test this PR.

Copy link

@ashok672 ashok672 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on the testing done by another team for sometime now.

@rayluo rayluo force-pushed the optional-portalocker branch from beb65a2 to 4b90cc8 Compare January 23, 2025 22:50
@rayluo rayluo merged commit 4b90cc8 into dev Jan 30, 2025
21 checks passed
@rayluo rayluo deleted the optional-portalocker branch January 30, 2025 07:07
@rayluo rayluo mentioned this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider removing portalocker dependency
3 participants