Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

context_managers: Open file in write mode in lockfile_nonblocking.

Mateusz Manderab572fa93cd99
diff --git a/zerver/lib/context_managers.py b/zerver/lib/context_managers.py
index 5010973e66f..8728d87dd28 100644
--- a/zerver/lib/context_managers.py
+++ b/zerver/lib/context_managers.py
@@ -37,7 +37,7 @@ def lockfile_nonblocking(filename: str) -> Iterator[bool]: # nocoverage
"""Lock a file using flock(2) for the duration of a 'with' statement.
Doesn't block, yields False immediately if the lock can't be acquired."""
- with open(filename) as f:
+ with open(filename, "w") as f:
lock_acquired = False
try:
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)