Skip to content
Snippets Groups Projects
Commit 7ad0798f authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

refactored the exception to proper module

parent f93b243a
No related branches found
Tags v1.0.3
No related merge requests found
......@@ -42,4 +42,4 @@ This is meant to acquire a lock on a file.
.. autoclass:: satella.posix.PIDFileLock
:members:
.. autoclass:: satella.posix.LockIsHeld
.. autoclass:: satella.exceptions.LockIsHeld
......@@ -73,3 +73,15 @@ class MetricAlreadyExists(BaseSatellaException):
self.name = name
self.requested_type = requested_type
self.existing_type = existing_type
class LockIsHeld(ResourceLocked):
"""
An exception raised when lock is held by someone
:param pid: PID of the holder, who is alive at the time this exception was raised.
This is checked via psutil.
"""
def __init__(self, pid):
self.pid = pid
\ No newline at end of file
......@@ -6,13 +6,13 @@ import os
import sys
from .daemon import daemonize
from .pidlock import PIDFileLock, LockIsHeld
from .pidlock import PIDFileLock
from satella.exceptions import LockIsHeld
from .signals import hang_until_sig
__all__ = [
'daemonize',
'PIDFileLock', 'LockIsHeld',
'hang_until_sig',
'PIDFileLock', 'hang_until_sig',
'is_running_as_root',
'suicide'
]
......
......@@ -3,18 +3,9 @@ import os
import psutil
logger = logging.getLogger(__name__)
class LockIsHeld(Exception):
"""
Lock is held by someone
from satella.exceptions import LockIsHeld
pid -- PID of the holder, who is alive
"""
def __init__(self, pid):
self.pid = pid
logger = logging.getLogger(__name__)
class PIDFileLock:
......
......@@ -5,7 +5,8 @@ import unittest
from mock import patch, Mock
from satella.posix import PIDFileLock, LockIsHeld
from satella.posix import PIDFileLock
from satella.exceptions import LockIsHeld
def acquire_lock_file_and_wait_for_signal(q, p):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment