Lines 2-8
Link Here
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
3 |
|
4 |
import os |
4 |
import os |
|
|
5 |
import pdb |
5 |
import signal |
6 |
import signal |
|
|
7 |
import sys |
6 |
|
8 |
|
7 |
try: |
9 |
try: |
8 |
import asyncio as _real_asyncio |
10 |
import asyncio as _real_asyncio |
Lines 53-58
class AsyncioEventLoop(_AbstractEventLoop):
Link Here
|
53 |
self.get_debug = loop.get_debug |
55 |
self.get_debug = loop.get_debug |
54 |
self._wakeup_fd = -1 |
56 |
self._wakeup_fd = -1 |
55 |
|
57 |
|
|
|
58 |
if portage._internal_caller: |
59 |
loop.set_exception_handler(self._internal_caller_exception_handler) |
60 |
|
61 |
@staticmethod |
62 |
def _internal_caller_exception_handler(loop, context): |
63 |
""" |
64 |
An exception handler which drops to a pdb shell if std* |
65 |
streams refer to a tty, and otherwise kills the process |
66 |
with SIGTERM. |
67 |
""" |
68 |
loop.default_exception_handler(context) |
69 |
if 'exception' in context: |
70 |
# If we have a tty then start the debugger, since in might |
71 |
# aid in diagnosis of the problem. If there's no tty, then |
72 |
# exit immediately. |
73 |
if all(s.isatty() for s in (sys.stdout, sys.stderr, sys.stdin)): |
74 |
pdb.set_trace() |
75 |
else: |
76 |
# Normally emerge will wait for all coroutines to complete |
77 |
# after SIGTERM has been received. However, an unhandled |
78 |
# exception will prevent the interrupted coroutine from |
79 |
# completing, therefore use the default SIGTERM handler |
80 |
# in order to ensure that emerge exits immediately (though |
81 |
# uncleanly). |
82 |
signal.signal(signal.SIGTERM, signal.SIG_DFL) |
83 |
os.kill(os.getpid(), signal.SIGTERM) |
84 |
|
56 |
def _create_future(self): |
85 |
def _create_future(self): |
57 |
""" |
86 |
""" |
58 |
Provide AbstractEventLoop.create_future() for python3.4. |
87 |
Provide AbstractEventLoop.create_future() for python3.4. |
59 |
- |
|
|