Lock files in binary mode, with one byte
This commit is contained in:
parent
cd9a965057
commit
a49f454826
1 changed files with 2 additions and 2 deletions
|
@ -36,7 +36,7 @@ def atomicWrite(dest, content, mode="wb"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def openLocked(path, mode="w"):
|
def openLocked(path, mode="wb"):
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
import fcntl
|
import fcntl
|
||||||
f = open(path, mode)
|
f = open(path, mode)
|
||||||
|
@ -44,7 +44,7 @@ def openLocked(path, mode="w"):
|
||||||
elif os.name == "nt":
|
elif os.name == "nt":
|
||||||
import msvcrt
|
import msvcrt
|
||||||
f = open(path, mode)
|
f = open(path, mode)
|
||||||
msvcrt.locking(f.fileno(), msvcrt.LK_NBLCK, -1)
|
msvcrt.locking(f.fileno(), msvcrt.LK_NBLCK, 1)
|
||||||
else:
|
else:
|
||||||
f = open(path, mode)
|
f = open(path, mode)
|
||||||
return f
|
return f
|
||||||
|
|
Loading…
Reference in a new issue