Skip to content

Commit

Permalink
Try "a" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 8, 2024
1 parent 0dc7baf commit 8927f45
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FileMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Amp\Sync\Mutex;
use Amp\Sync\SyncException;
use function Amp\delay;
use const Amp\Process\IS_WINDOWS;

final class FileMutex implements Mutex
{
Expand Down Expand Up @@ -39,7 +40,7 @@ public function acquire(?Cancellation $cancellation = null): Lock
// so set an asynchronous timer and try again.
for ($attempt = 0; true; ++$attempt) {
try {
$file = $this->filesystem->openFile($this->fileName, 'c');
$file = $this->filesystem->openFile($this->fileName, 'a');
if ($file->lock(LockMode::Exclusive)) {
return new Lock(fn () => $this->release($file));
}
Expand Down

0 comments on commit 8927f45

Please sign in to comment.