Repository navigation
feat(fs): add tryLock(exclusive?: boolean): Promise<boolean> to FsFile - #31848
Conversation
Implements non-blocking file lock attempt for Deno.FsFile. - Add tryLock() and tryLockSync() methods to FsFile - Returns true on successful lock acquisition - Returns false when lock cannot be acquired (non-blocking) - Uses fs3::try_lock_exclusive/try_lock_shared under the hood Closes #31343
|
@dsherret could you please have a look at my PR when you get a chance? I'm open to any feedback or suggestions. thanks! |
|
Do you have any other feedback for me? |
dsherret
left a comment
There was a problem hiding this comment.
LGTM, but not approving yet because we'll wait until closer to the 2.7 release to get this merged.
|
I just saw 2.7.0 is scheduled for Feb 24 — do I have to wait until then? |
|
We might merge it sooner, but we’ll have to wait a bit.
For sure. |
|
@dsherret will close it for now. please let me know when you are ready for merging so that I can reopen the PR. |
|
Why? It’s in the 2.7 milestone. |
|
I’ve been working on gittensor.io, which incentivizes contributors when their pull requests are merged. However, if a pull request is opened but not merged, I receive a penalty. |
|
@dsherret could you please let me know when you can merge it exactly? |
|
I don't want to change our process for this or create additional an additional administration burden. We sometimes often change when minor releases happen. You can consider closing this PR, but someone else might open a new PR in the meantime because they see at a glance that this one is closed. I opened entrius/gittensor#141 to ask for the ability to exclude repositories form the open pr penalty. |
|
Okay, will leave it open for now |
feat(fs): add
tryLockmethod toDeno.FsFileCloses #31343
Description
This PR adds a non-blocking file lock method to
Deno.FsFile. Currently,lock()andlockSync()block until the lock is acquired, which can be problematic when you want to check if a file is available without waiting indefinitely.The new
tryLock()method attempts to acquire a lock and immediately returns a boolean indicating success, rather than blocking.Changes
Added two new methods to
Deno.FsFile:Behavior:
trueif the lock was successfully acquiredfalseif the file is already locked (non-blocking, does not wait)Example Usage
Implementation Details
fs3::FileExt::try_lock_exclusive()andtry_lock_shared()under the hoodEWOULDBLOCK/WouldBlockerrors by returningfalseinstead of throwinglock()/lockSync()methodsTest Plan
Added unit tests in
tests/unit/files_test.ts:fsFileTryLockSync- verifies sync exclusive lock behaviorfsFileTryLockAsync- verifies async exclusive lock behaviorfsFileTryLockSharedSync- verifies shared locks can coexistChecklist
tryLock(exclusive?: boolean) : Promise<boolean>intoDeno.FsFile#31343)cargo checkpassescargo clippypassesdeno lintpasses on modified JS files