commit:     65379f436759dfbc4d56e52f1a145950779ebb60
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 16:45:27 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 16:57:38 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=65379f43

AsyncioEventLoop: suppress BlockingIOError warning during loop close (bug 
655656)

Disable the asyncio event loop's SIGCHLD handler before attempting
to close it, in order to suppress a harmless BlockingIOError warning
during loop close.

Closes: https://bugs.gentoo.org/655656
Reported-by: Helmut Jarausch <jarausch <AT> igpm.rwth-aachen.de>

 pym/portage/util/_eventloop/asyncio_event_loop.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pym/portage/util/_eventloop/asyncio_event_loop.py 
b/pym/portage/util/_eventloop/asyncio_event_loop.py
index b365939b0..bf5937de8 100644
--- a/pym/portage/util/_eventloop/asyncio_event_loop.py
+++ b/pym/portage/util/_eventloop/asyncio_event_loop.py
@@ -1,6 +1,8 @@
 # Copyright 2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import signal
+
 try:
        import asyncio as _real_asyncio
        from asyncio.events import AbstractEventLoop as _AbstractEventLoop
@@ -31,7 +33,6 @@ class AsyncioEventLoop(_AbstractEventLoop):
                self.call_at = loop.call_at
                self.is_running = loop.is_running
                self.is_closed = loop.is_closed
-               self.close = loop.close
                self.create_future = (loop.create_future
                        if hasattr(loop, 'create_future') else 
self._create_future)
                self.create_task = loop.create_task
@@ -75,3 +76,10 @@ class AsyncioEventLoop(_AbstractEventLoop):
                @return: the internal event loop's AbstractEventLoop interface
                """
                return self
+
+       def close(self):
+               # Suppress spurious error messages like the following for bug 
655656:
+               #   Exception ignored when trying to write to the signal wakeup 
fd:
+               #   BlockingIOError: [Errno 11] Resource temporarily unavailable
+               self._loop.remove_signal_handler(signal.SIGCHLD)
+               self._loop.close()

Reply via email to