MCPcopy Index your code
hub / github.com/MagicStack/asyncpg / _format_loop_exception

Method _format_loop_exception

asyncpg/_testbase/__init__.py:183–215  ·  view source on GitHub ↗
(self, context, n)

Source from the content-addressed store, hash-verified

181 loop.default_exception_handler(context)
182
183 def _format_loop_exception(self, context, n):
184 message = context.get('message', 'Unhandled exception in event loop')
185 exception = context.get('exception')
186 if exception is not None:
187 exc_info = (type(exception), exception, exception.__traceback__)
188 else:
189 exc_info = None
190
191 lines = []
192 for key in sorted(context):
193 if key in {'message', 'exception'}:
194 continue
195 value = context[key]
196 if key == 'source_traceback':
197 tb = ''.join(traceback.format_list(value))
198 value = 'Object created at (most recent call last):\n'
199 value += tb.rstrip()
200 else:
201 try:
202 value = repr(value)
203 except Exception as ex:
204 value = ('Exception in __repr__ {!r}; '
205 'value type: {!r}'.format(ex, type(value)))
206 lines.append('[{}]: {}\n\n'.format(key, value))
207
208 if exc_info is not None:
209 lines.append('[exception]:\n')
210 formatted_exc = textwrap.indent(
211 ''.join(traceback.format_exception(*exc_info)), ' ')
212 lines.append(formatted_exc)
213
214 details = textwrap.indent(''.join(lines), ' ')
215 return '{:02d}. {}:\n{}\n'.format(n, message, details)
216
217
218_default_cluster = None

Callers 1

tearDownMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected