Skip to content

Commit 2b43901

Browse files
committed
Remove python-daemon dependency
remove python-daemon since it uses unsupported dependency 'lockfile' Fixes: #379 Signed-off-by: Abhijeet Kasurde <[email protected]>
1 parent 6a53a5d commit 2b43901

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

ansible_runner/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from ansible_runner import cleanup
4343
from ansible_runner.utils import dump_artifact, Bunch, register_for_cleanup
4444
from ansible_runner.utils.capacity import get_cpu_count, get_mem_in_bytes, ensure_uuid
45+
from ansible_runner.utils.locks import TimeoutProcessLock
4546
from ansible_runner.runner import Runner
4647
from ansible_runner.exceptions import AnsibleRunnerException
4748

@@ -814,9 +815,7 @@ def main(sys_args=None):
814815
if vargs.get('command') in ('start', 'run', 'transmit', 'worker', 'process'):
815816

816817
if vargs.get('command') == 'start':
817-
import daemon
818-
from daemon.pidfile import TimeoutPIDLockFile
819-
context = daemon.DaemonContext(pidfile=TimeoutPIDLockFile(pidfile))
818+
context = TimeoutProcessLock(pidfile).locked(5)
820819
else:
821820
context = threading.Lock()
822821

ansible_runner/exceptions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
21
class AnsibleRunnerException(Exception):
3-
""" Generic Runner Error """
2+
"""Generic Runner Error"""
43

54

65
class ConfigurationError(AnsibleRunnerException):
7-
""" Misconfiguration of Runner """
6+
"""Misconfiguration of Runner"""
87

98

109
class CallbackError(AnsibleRunnerException):
11-
""" Exception occurred in Callback """
10+
"""Exception occurred in Callback"""
11+
12+
13+
class ProcessLockException(Exception):
14+
"""Exception occurred in Locking process using fasteners"""

ansible_runner/utils/locks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from contextlib import contextmanager
2+
from fasteners import InterProcessLock
3+
from ansible_runner.exceptions import ProcessLockException
4+
5+
6+
class TimeoutProcessLock(InterProcessLock):
7+
8+
@contextmanager
9+
def locked(self, timeout):
10+
ok = self.acquire(timeout=timeout)
11+
if not ok:
12+
raise ProcessLockException()
13+
try:
14+
yield
15+
finally:
16+
self.release()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pexpect>=4.5
22
packaging
3-
python-daemon
3+
fasteners>=0.16
44
pyyaml
55
six

tools/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ pypsrp[kerberos,credssp]
66
pywinrm[kerberos,credssp]
77
toml
88
pexpect>=4.5
9-
python-daemon
9+
fasteners>=0.16
1010
pyyaml
1111
six

0 commit comments

Comments
 (0)