From 0e64c529b42ce6c7ae3fe8ea3b1de6baf287f373 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 14 Jul 2008 09:00:03 +0000 Subject: [PATCH] Unregister from poll() objects before closing file in order to hopefully avoid stale events that can trigger a KeyError in Scheduler._poll_loop() if the event's file descriptor no longer has a registered handler. svn path=/main/trunk/; revision=11047 --- pym/_emerge/__init__.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index c02849995..a60d33950 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1726,11 +1726,13 @@ class PipeReader(AsynchronousTask): if buf: self._read_data.append(buf.tostring()) else: - for f in files.values(): - f.close() self.registered = False for reg_id in self._reg_ids: self.scheduler.unregister(reg_id) + + for f in files.values(): + f.close() + self.wait() return self.registered @@ -2069,12 +2071,12 @@ class SpawnProcess(SubProcess): buf.tofile(files.out) files.out.flush() else: - fd = files.process.fileno() - for f in files.values(): - f.flush() - f.close() self.registered = False self.scheduler.unregister(self._reg_id) + + for f in files.values(): + f.close() + self.wait() return self.registered @@ -2093,11 +2095,12 @@ class SpawnProcess(SubProcess): if buf: pass else: - fd = files.process.fileno() - for f in files.values(): - f.close() self.registered = False self.scheduler.unregister(self._reg_id) + + for f in files.values(): + f.close() + self.wait() return self.registered @@ -2562,10 +2565,12 @@ class EbuildMetadataPhase(SubProcess): files = self.files self._raw_metadata.append(files.ebuild.read()) if not self._raw_metadata[-1]: - for f in files.values(): - f.close() self.registered = False self.scheduler.unregister(self._reg_id) + + for f in files.values(): + f.close() + self.wait() if self.returncode == os.EX_OK: @@ -2687,11 +2692,12 @@ class EbuildPhase(SubProcess): buf.tofile(files.log) files.log.flush() else: - fd = files.ebuild.fileno() - for f in files.values(): - f.close() self.registered = False self.scheduler.unregister(self._reg_id) + + for f in files.values(): + f.close() + self.wait() return self.registered @@ -2710,11 +2716,12 @@ class EbuildPhase(SubProcess): if buf: pass else: - fd = files.ebuild.fileno() - for f in files.values(): - f.close() self.registered = False self.scheduler.unregister(self._reg_id) + + for f in files.values(): + f.close() + self.wait() return self.registered -- 2.26.2