commit:     30150206fb0b3e013ef5b163b8d2f24c70a9d977
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Mar  2 04:56:49 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Mar  2 05:01:06 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=30150206

AsyncioEventLoop: always die with SIGTERM in exception handler (bug 705910)

Remove call to pdb.set_trace() in exception handler, since it's
not very useful, and always die with a SIGTERM for unexpected
exceptions here.

Bug: https://bugs.gentoo.org/705910
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/util/_eventloop/asyncio_event_loop.py | 31 +++++++----------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py 
b/lib/portage/util/_eventloop/asyncio_event_loop.py
index a11a10205..ce7e06923 100644
--- a/lib/portage/util/_eventloop/asyncio_event_loop.py
+++ b/lib/portage/util/_eventloop/asyncio_event_loop.py
@@ -1,10 +1,8 @@
-# Copyright 2018 Gentoo Foundation
+# Copyright 2018-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import os
-import pdb
 import signal
-import sys
 
 try:
        import asyncio as _real_asyncio
@@ -69,25 +67,14 @@ class AsyncioEventLoop(_AbstractEventLoop):
                """
                loop.default_exception_handler(context)
                if 'exception' in context:
-                       # If we have a tty then start the debugger, since in 
might
-                       # aid in diagnosis of the problem. If there's no tty, 
then
-                       # exit immediately.
-                       if all(s.isatty() for s in (sys.stdout, sys.stderr, 
sys.stdin)):
-                               # Restore default SIGINT handler, since 
emerge's Scheduler
-                               # has a SIGINT handler which delays exit until 
after
-                               # cleanup, and cleanup cannot occur here since 
the event
-                               # loop is suspended (see bug 672540).
-                               signal.signal(signal.SIGINT, signal.SIG_DFL)
-                               pdb.set_trace()
-                       else:
-                               # Normally emerge will wait for all coroutines 
to complete
-                               # after SIGTERM has been received. However, an 
unhandled
-                               # exception will prevent the interrupted 
coroutine from
-                               # completing, therefore use the default SIGTERM 
handler
-                               # in order to ensure that emerge exits 
immediately (though
-                               # uncleanly).
-                               signal.signal(signal.SIGTERM, signal.SIG_DFL)
-                               os.kill(os.getpid(), signal.SIGTERM)
+                       # Normally emerge will wait for all coroutines to 
complete
+                       # after SIGTERM has been received. However, an unhandled
+                       # exception will prevent the interrupted coroutine from
+                       # completing, therefore use the default SIGTERM handler
+                       # in order to ensure that emerge exits immediately 
(though
+                       # uncleanly).
+                       signal.signal(signal.SIGTERM, signal.SIG_DFL)
+                       os.kill(os.getpid(), signal.SIGTERM)
 
        def _create_future(self):
                """

Reply via email to