diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py index 993157b..9eeac35 100644 --- a/oslo_concurrency/tests/unit/test_lockutils.py +++ b/oslo_concurrency/tests/unit/test_lockutils.py @@ -14,6 +14,7 @@ import collections import errno +import fcntl import multiprocessing import os import signal @@ -30,25 +31,6 @@ from oslo_concurrency.fixture import lockutils as fixtures from oslo_concurrency import lockutils from oslo_config import fixture as config -if sys.platform == 'win32': - import msvcrt -else: - import fcntl - - -def lock_file(handle): - if sys.platform == 'win32': - msvcrt.locking(handle.fileno(), msvcrt.LK_NBLCK, 1) - else: - fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB) - - -def unlock_file(handle): - if sys.platform == 'win32': - msvcrt.locking(handle.fileno(), msvcrt.LK_UNLCK, 1) - else: - fcntl.flock(handle, fcntl.LOCK_UN) - def lock_files(handles_dir, out_queue): with lockutils.lock('external', 'test-', external=True): @@ -65,9 +47,9 @@ def lock_files(handles_dir, out_queue): count = 0 for handle in handles: try: - lock_file(handle) + fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB) count += 1 - unlock_file(handle) + fcntl.flock(handle, fcntl.LOCK_UN) except OSError: os._exit(2) finally: