Pylint cleanup

This commit is contained in:
Thomas Jackson 2014-09-06 15:45:15 -07:00
parent 56357e7d78
commit 4a83d8a9c3
4 changed files with 11 additions and 10 deletions

View File

@ -4,9 +4,6 @@ The main entry point for salt-api
'''
# Import python libs
import logging
import multiprocessing
import signal
import os
# Import salt-api libs
import salt.loader

View File

@ -9,7 +9,6 @@ import os
import re
import time
import errno
import signal
import shutil
import logging
import hashlib
@ -45,7 +44,6 @@ import salt.utils.gzip_util
import salt.utils.process
from salt.defaults import DEFAULT_TARGET_DELIM
from salt.utils.debug import enable_sigusr1_handler, enable_sigusr2_handler, inspect_stack
from salt.exceptions import MasterExit
from salt.utils.event import tagify
import binascii
from salt.utils.master import ConnectedCache

View File

@ -112,6 +112,7 @@ def os_is_running(pid):
except OSError:
return False
class ProcessManager(object):
'''
A class which will manage processes that should be running
@ -124,12 +125,18 @@ class ProcessManager(object):
if self.name is None:
self.name = self.__class__.__name__
def add_process(self, tgt, args=[], kwargs={}):
def add_process(self, tgt, args=None, kwargs=None):
'''
Create a processes and args + kwargs
This will deterimine if it is a Process class, otherwise it assumes
it is a function
'''
if args is None:
args = []
if kwargs is None:
kwargs = {}
if type(multiprocessing.Process) == type(tgt) and issubclass(tgt, multiprocessing.Process):
p = tgt(*args, **kwargs)
else:

View File

@ -7,12 +7,11 @@ import signal
import multiprocessing
# Import Salt Testing libs
from salttesting import skipIf, TestCase
from salttesting import TestCase
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
import salt.utils.process
@ -72,9 +71,9 @@ class TestProcessManager(TestCase):
counter = multiprocessing.Value('i', 0)
process_manager = salt.utils.process.ProcessManager()
process_manager.add_process(incr, args=(counter, 2))
time.sleep(0.1)
time.sleep(1)
process_manager.check_children()
time.sleep(0.1)
time.sleep(1)
# we should have had 2 processes go at it
assert counter.value == 4
process_manager.kill_children()