MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / _format_loop_exception

Method _format_loop_exception

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

Source from the content-addressed store, hash-verified

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

Callers 1

tearDownMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected