Download cloud-v2/packages/cli/src/testing/lock-worker.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/cloud-v2/packages/cli/src/testing/lock-worker.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/cloud-v2/packages/cli/src/testing/lock-worker.ts
-
curl -L -o lock-worker.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/cloud-v2/packages/cli/src/testing/lock-worker.ts
752 Bytes
| /** | |
| * A separate process for the lock tests: takes `<lock>` `<rounds>` times and appends each | |
| * holding interval (`start end` in ms) to `<log>`. | |
| * | |
| * bun src/testing/lock-worker.ts <lock> <log> <rounds> | |
| */ | |
| import {appendFileSync} from "node:fs" | |
| import {withFileLock} from "../file-lock" | |
| const [lock, log, rounds] = process.argv.slice(2) | |
| for (let round = 0; round < Number(rounds); round += 1) { | |
| await withFileLock(lock!, {staleMs: 5_000, waitMs: 20_000, busyMessage: "busy"}, async () => { | |
| const start = performance.timeOrigin + performance.now() | |
| await new Promise(resolve => setTimeout(resolve, 15)) | |
| const end = performance.timeOrigin + performance.now() | |
| appendFileSync(log!, `${start} ${end}\n`) | |
| }) | |
| } | |