def _read_completed(self, data): """ Called when dd process has closed stderr. At this point the process may be still running. """ assert self._state is not IDLE self._reader = None self._err = data rc = self._proc.poll() # About 95% of runs, the process has terminated at this point. If not, # start the reaper to wait for it. if rc is None: self._reaper = asyncevent.Reaper(self._loop, self._proc, self._check_completed) return self._check_completed(rc)
def _read_completed(self, data): """ Called when dd process has closed stderr. At this point the process may be still running. """ assert self._state is not IDLE self._reader = None # Avoid leaking self._proc.stderr. The pipe should be closed # automatically after we clear the reference to self._proc, but we see # clear leak for every failing check. # See https://bugzilla.redhat.com/2075795 self._proc.stderr.close() self._err = data rc = self._proc.poll() # About 95% of runs, the process has terminated at this point. If not, # start the reaper to wait for it. if rc is None: self._reaper = asyncevent.Reaper(self._loop, self._proc, self._check_completed) return self._check_completed(rc)
def reap(self, cmd): proc = subprocess.Popen(cmd, stdin=None, stdout=None, stderr=None) asyncevent.Reaper(self.loop, proc, self.complete) self.loop.run_forever()