Skip to content

Commit 1be24f5

Browse files
committed
Remove pytest_services.locks.lock_file (and the remaining reference to fcntl)
1 parent a436b15 commit 1be24f5

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Changelog
1010
- #29: Fix issues with later versions of mysql where ``mysql_defaults_file``
1111
fixture would prevent startup of mysql.
1212
- Fixed issue in test suite where mysql fixture was not tested.
13+
- Removed ``pytest_services.locks.lock_file``.
1314

1415
1.3.1
1516
-----

pytest_services/locks.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fixtures for supporting a distributed test run."""
22
import contextlib
3-
import errno
4-
import fcntl
53
import json
64
import os
75
import socket
@@ -12,32 +10,6 @@
1210
marker = object()
1311

1412

15-
def lock_file(filename, content, operation):
16-
"""Lock given file.
17-
18-
:param filename: full path to the lockfile
19-
:param content: content string to write to the lockfile after successful lock
20-
:param operation: os operation to use for lock
21-
:return: file object of opened locked file. Can be used to write content to it
22-
"""
23-
try:
24-
handle = os.fdopen(os.open(filename, os.O_RDWR | os.O_CREAT, 0o666), 'r+')
25-
except OSError as e:
26-
if e.errno == errno.EACCES:
27-
raise Exception('Failed to open/create file. Check permissions on containing folder')
28-
raise
29-
fcntl.flock(handle, operation)
30-
if content:
31-
handle.write(content)
32-
handle.flush()
33-
os.fsync(handle.fileno())
34-
try:
35-
os.chmod(filename, 0o666)
36-
except OSError:
37-
pass
38-
return handle
39-
40-
4113
def try_remove(filename):
4214
try:
4315
os.unlink(filename)

0 commit comments

Comments
 (0)