Loading cloudcontrol/node/jobs.py +19 −11 Original line number Diff line number Diff line Loading @@ -145,8 +145,8 @@ class BaseThreadedJob(Thread): self.running = False class BaseIOJob(object): """Job that can set ionice and executes in a fork. class ForkedJob(object): """Job that executes in a fork. When inherit, you must define open_fds property that list file descriptors that must be kept in the child and closed in the parent. Loading @@ -156,8 +156,6 @@ class BaseIOJob(object): to occur, see http://bugs.python.org/issue6721 """ IO_NICE = 7 def __init__(self, job_manager): self.job_manager = job_manager Loading @@ -178,12 +176,9 @@ class BaseIOJob(object): # overide in sub class pass def set_io_nice(self): try: subprocess.check_call(['ionice', '-n%d' % self.IO_NICE, '-p%d' % os.getpid()], close_fds=True) except subprocess.CalledProcessError as exc: sys.stderr.write('Cannot set ionice, return code %s\n' % exc.returncode) def after_fork(self): # overide in sub class pass def close_fds(self): """Close all fds uneeded fds in children.""" Loading Loading @@ -231,7 +226,7 @@ class BaseIOJob(object): # child self.reset_signal_mask() self.close_fds() self.set_io_nice() self.after_fork() try: self.run_job() except: Loading Loading @@ -295,3 +290,16 @@ class BaseIOJob(object): def join(self): self.job_done.wait() class BaseIOJob(ForkedJob): """Fork job that set ionice on the child.""" IO_NICE = 7 def after_fork(self): try: subprocess.check_call(['ionice', '-n%d' % self.IO_NICE, '-p%d' % os.getpid()], close_fds=True) except subprocess.CalledProcessError as exc: sys.stderr.write('Cannot set ionice, return code %s\n' % exc.returncode) Loading
cloudcontrol/node/jobs.py +19 −11 Original line number Diff line number Diff line Loading @@ -145,8 +145,8 @@ class BaseThreadedJob(Thread): self.running = False class BaseIOJob(object): """Job that can set ionice and executes in a fork. class ForkedJob(object): """Job that executes in a fork. When inherit, you must define open_fds property that list file descriptors that must be kept in the child and closed in the parent. Loading @@ -156,8 +156,6 @@ class BaseIOJob(object): to occur, see http://bugs.python.org/issue6721 """ IO_NICE = 7 def __init__(self, job_manager): self.job_manager = job_manager Loading @@ -178,12 +176,9 @@ class BaseIOJob(object): # overide in sub class pass def set_io_nice(self): try: subprocess.check_call(['ionice', '-n%d' % self.IO_NICE, '-p%d' % os.getpid()], close_fds=True) except subprocess.CalledProcessError as exc: sys.stderr.write('Cannot set ionice, return code %s\n' % exc.returncode) def after_fork(self): # overide in sub class pass def close_fds(self): """Close all fds uneeded fds in children.""" Loading Loading @@ -231,7 +226,7 @@ class BaseIOJob(object): # child self.reset_signal_mask() self.close_fds() self.set_io_nice() self.after_fork() try: self.run_job() except: Loading Loading @@ -295,3 +290,16 @@ class BaseIOJob(object): def join(self): self.job_done.wait() class BaseIOJob(ForkedJob): """Fork job that set ionice on the child.""" IO_NICE = 7 def after_fork(self): try: subprocess.check_call(['ionice', '-n%d' % self.IO_NICE, '-p%d' % os.getpid()], close_fds=True) except subprocess.CalledProcessError as exc: sys.stderr.write('Cannot set ionice, return code %s\n' % exc.returncode)