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 11"""Shared functions and other definitions."""
22import collections
3+ import fcntl
34import importlib .metadata
45import os
56import random
1718from itertools import zip_longest
1819from pathlib import Path , PurePosixPath
1920from tempfile import NamedTemporaryFile
20- from types import ModuleType
2121from typing import (
2222 IO ,
2323 TYPE_CHECKING ,
@@ -241,29 +241,12 @@ def random_outdir() -> str:
241241 return __random_outdir
242242
243243
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-
255244def 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 )
260246
261247
262248def 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 )
267250
268251
269252def adjustFileObjs (rec : Any , op : Union [Callable [..., Any ], "partial[Any]" ]) -> None :
You can’t perform that action at this time.
0 commit comments