From: Zac Medico Date: Fri, 4 Jan 2013 06:08:56 +0000 (-0800) Subject: PipeReader: support plain fd without file obj X-Git-Tag: v2.2.0_alpha150~43 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9d4fdf7ec5ccd4b78cbce2d7209ce91286fbbf26;p=portage.git PipeReader: support plain fd without file obj --- diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index bb4e0dc1c..be93be323 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -35,9 +35,10 @@ class PipeReader(AbstractPollTask): fcntl_flags |= fcntl.FD_CLOEXEC for f in self.input_files.values(): - fcntl.fcntl(f.fileno(), fcntl.F_SETFL, - fcntl.fcntl(f.fileno(), fcntl.F_GETFL) | fcntl_flags) - self._reg_ids.add(self.scheduler.io_add_watch(f.fileno(), + fd = isinstance(f, int) and f or f.fileno() + fcntl.fcntl(fd, fcntl.F_SETFL, + fcntl.fcntl(fd, fcntl.F_GETFL) | fcntl_flags) + self._reg_ids.add(self.scheduler.io_add_watch(fd, self._registered_events, output_handler)) self._registered = True @@ -113,6 +114,9 @@ class PipeReader(AbstractPollTask): if self.input_files is not None: for f in self.input_files.values(): - f.close() + if isinstance(f, int): + os.close(f) + else: + f.close() self.input_files = None