Handle Python 3's O_CLOEXEC default
In Python 2, a file opened by a process was inherited by all of its children. Python 3 sets the O_CLOEXEC flag on the file descriptor by default so this doesn't happen. Because of the Python 2 behavior, our test code explicitly closes the file descriptor in one test, but we shouldn't be doing that since it wouldn't happen in a real usage scenario. Fortunately, it appears both cases work in a sane fashion anyway. With the explicit release removed from the child process, the py2 tests still run fine, and with that done the py3 tests no longer have a problem either. This is fortunate because if the py2 behavior allowed multiple processes to hold the lock at once it would obviously be a Bad Thing. :-) Change-Id: I133334dee068984b1309180c5338ac19d9934274
This commit is contained in:
parent
394fbf4f04
commit
2dae1fd780
@ -53,7 +53,6 @@ class LockTestCase(test_base.BaseTestCase):
|
||||
lock = lockutils._FcntlLock(lock_file)
|
||||
|
||||
def try_lock():
|
||||
lock.release() # child co-owns it before fork
|
||||
try:
|
||||
my_lock = lockutils._FcntlLock(lock_file)
|
||||
my_lock.lockfile = open(lock_file, 'w')
|
||||
|
Loading…
x
Reference in New Issue
Block a user