def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" # NOTE(zhaochao): all child processes should always be killed even the # context exits by an exception. if getattr(self, 'process', None): try: # Send a sigterm to the session leader, so that all # child processes are killed and cleaned up on terminate # (Ensures zombie processes aren't left around on a FAILURE) # https://bugs.launchpad.net/trove/+bug/1253850 os.killpg(self.process.pid, signal.SIGTERM) self.process.terminate() except OSError: # Already stopped pass if exc_type is not None: return False utils.raise_if_process_errored(self.process, BackupError) if not self.check_process(): raise BackupError self._run_post_backup() return True
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is None: utils.raise_if_process_errored(self.process, DownloadError) # Make sure to terminate the process try: self.process.terminate() except OSError: # Already stopped pass
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is None: utils.raise_if_process_errored(self.process, DownloadError) # Make sure to terminate the process try: self.process.terminate() except OSError: # Already stopped pass
def __exit__(self, exc_type, exc_value, traceback): if exc_type is not None: return False if hasattr(self, 'prepare_process'): try: self.prepare_process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.prepare_process, base.RestoreError) return True
def _unpack(self, location, checksum, command): stream = self.storage.load(location, checksum) process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE) content_length = 0 for chunk in stream: process.stdin.write(chunk) content_length += len(chunk) process.stdin.close() utils.raise_if_process_errored(process, RestoreError) LOG.info(_("Restored %s bytes from stream.") % content_length) return content_length
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is not None: return False if hasattr(self, "process"): try: self.process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.process, RestoreError) return True
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is not None: return False if hasattr(self, 'process'): try: self.process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.process, RestoreError) return True
def _unpack(self, location, checksum, command): stream = self.storage.load(location, checksum) process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE) content_length = 0 for chunk in stream: process.stdin.write(chunk) content_length += len(chunk) process.stdin.close() utils.raise_if_process_errored(process, RestoreError) LOG.debug("Restored %s bytes from stream.", content_length) return content_length
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is not None: return False if hasattr(self, 'process'): try: self.process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.process, BackupError) if not self.check_process(): raise BackupError return True
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is not None: return False if hasattr(self, 'process'): try: # Send a sigterm to the session leader, so that all # child processes are killed and cleaned up on terminate # (Ensures zombie processes aren't left around on a FAILURE) # https://bugs.launchpad.net/trove/+bug/1253850 os.killpg(self.process.pid, signal.SIGTERM) self.process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.process, BackupError) if not self.check_process(): raise BackupError return True
def __exit__(self, exc_type, exc_value, traceback): """Clean up everything.""" if exc_type is not None: return False if hasattr(self, 'process'): try: # Send a sigterm to the session leader, so that all # child processes are killed and cleaned up on terminate # (Ensures zombie processes aren't left around on a FAILURE) # https://bugs.launchpad.net/trove/+bug/1253850 os.killpg(self.process.pid, signal.SIGTERM) self.process.terminate() except OSError: # Already stopped pass utils.raise_if_process_errored(self.process, BackupError) if not self.check_process(): raise BackupError return True