Skip to content

Commit 2ac1d2b

Browse files
committed
Add type hints and move setting of lock flags
1 parent 850ac58 commit 2ac1d2b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

buildrunner/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ def _acquire_flock_open(
217217
@timeout_decorator.timeout(
218218
seconds=timeout_seconds, timeout_exception=FailureToAcquireLockException
219219
)
220-
def get_lock(file_obj, flags):
220+
def get_lock(file_obj: io.IOBase):
221+
flags = (
222+
portalocker.LockFlags.EXCLUSIVE
223+
if exclusive
224+
else portalocker.LockFlags.SHARED
225+
)
221226
portalocker.lock(
222227
file_obj,
223228
flags,
@@ -230,12 +235,7 @@ def get_lock(file_obj, flags):
230235
pid = os.getpid()
231236

232237
try:
233-
flags = (
234-
portalocker.LockFlags.EXCLUSIVE
235-
if exclusive
236-
else portalocker.LockFlags.SHARED
237-
)
238-
lock_file_obj = get_lock(file_obj, flags)
238+
lock_file_obj = get_lock(file_obj)
239239
except FailureToAcquireLockException:
240240
file_obj.close()
241241
raise FailureToAcquireLockException(

0 commit comments

Comments
 (0)