File tree Expand file tree Collapse file tree 1 file changed +3
-20
lines changed Expand file tree Collapse file tree 1 file changed +3
-20
lines changed Original file line number Diff line number Diff line change 1
1
"""Shared functions and other definitions."""
2
2
import collections
3
+ import fcntl
3
4
import importlib .metadata
4
5
import os
5
6
import random
17
18
from itertools import zip_longest
18
19
from pathlib import Path , PurePosixPath
19
20
from tempfile import NamedTemporaryFile
20
- from types import ModuleType
21
21
from typing import (
22
22
IO ,
23
23
TYPE_CHECKING ,
@@ -241,29 +241,12 @@ def random_outdir() -> str:
241
241
return __random_outdir
242
242
243
243
244
- #
245
- # Simple multi-platform (fcntl/msvrt) file locking wrapper
246
- #
247
- fcntl : Optional [ModuleType ] = None
248
- msvcrt : Optional [ModuleType ] = None
249
- try :
250
- import fcntl
251
- except ImportError :
252
- import msvcrt
253
-
254
-
255
244
def shared_file_lock (fd : IO [Any ]) -> None :
256
- if fcntl :
257
- fcntl .flock (fd .fileno (), fcntl .LOCK_SH )
258
- elif msvcrt :
259
- msvcrt .locking (fd .fileno (), msvcrt .LK_LOCK , 1024 )
245
+ fcntl .flock (fd .fileno (), fcntl .LOCK_SH )
260
246
261
247
262
248
def upgrade_lock (fd : IO [Any ]) -> None :
263
- if fcntl :
264
- fcntl .flock (fd .fileno (), fcntl .LOCK_EX )
265
- elif msvcrt :
266
- pass
249
+ fcntl .flock (fd .fileno (), fcntl .LOCK_EX )
267
250
268
251
269
252
def adjustFileObjs (rec : Any , op : Union [Callable [..., Any ], "partial[Any]" ]) -> None :
You can’t perform that action at this time.
0 commit comments