File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 33import sys
44import errno
55import portalocker
6+ from distutils .version import LooseVersion
67
78
89class CrossPlatLock (object ):
@@ -12,6 +13,8 @@ class CrossPlatLock(object):
1213 """
1314 def __init__ (self , lockfile_path ):
1415 self ._lockpath = lockfile_path
16+ # Support for passing through arguments to the open syscall was added in v1.4.0
17+ open_kwargs = {'buffering' : 0 } if LooseVersion (portalocker .__version__ ) >= LooseVersion ("1.4.0" ) else {}
1518 self ._lock = portalocker .Lock (
1619 lockfile_path ,
1720 mode = 'wb+' ,
@@ -20,7 +23,7 @@ def __init__(self, lockfile_path):
2023 # More information here:
2124 # https://docs.python.org/3/library/fcntl.html#fcntl.lockf
2225 flags = portalocker .LOCK_EX | portalocker .LOCK_NB ,
23- buffering = 0 )
26+ ** open_kwargs )
2427
2528 def __enter__ (self ):
2629 file_handle = self ._lock .__enter__ ()
You can’t perform that action at this time.
0 commit comments