MCPcopy
hub / github.com/django/django / check_picklable

Method check_picklable

django/test/runner.py:225–274  ·  view source on GitHub ↗
(self, test, err)

Source from the content-addressed store, hash-verified

223""".format(test, subtest, pickle_exc))
224
225 def check_picklable(self, test, err):
226 # Ensure that sys.exc_info() tuples are picklable. This displays a
227 # clear multiprocessing.pool.RemoteTraceback generated in the child
228 # process instead of a multiprocessing.pool.MaybeEncodingError, making
229 # the root cause easier to figure out for users who aren't familiar
230 # with the multiprocessing module. Since we're in a forked process,
231 # our best chance to communicate with them is to print to stdout.
232 try:
233 self._confirm_picklable(err)
234 except Exception as exc:
235 original_exc_txt = repr(err[1])
236 original_exc_txt = textwrap.fill(
237 original_exc_txt, 75, initial_indent=" ", subsequent_indent=" "
238 )
239 pickle_exc_txt = repr(exc)
240 pickle_exc_txt = textwrap.fill(
241 pickle_exc_txt, 75, initial_indent=" ", subsequent_indent=" "
242 )
243 if tblib is None:
244 print("""
245
246{} failed:
247
248{}
249
250Unfortunately, tracebacks cannot be pickled, making it impossible for the
251parallel test runner to handle this exception cleanly.
252
253In order to see the traceback, you should install tblib:
254
255 python -m pip install tblib
256""".format(test, original_exc_txt))
257 else:
258 print("""
259
260{} failed:
261
262{}
263
264Unfortunately, the exception it raised cannot be pickled, making it impossible
265for the parallel test runner to handle it cleanly.
266
267Here's the error encountered while trying to pickle the exception:
268
269{}
270
271You should re-run this test with the --parallel=1 option to reproduce the
272failure and get a correct traceback.
273""".format(test, original_exc_txt, pickle_exc_txt))
274 raise
275
276 def check_subtest_picklable(self, test, subtest):
277 try:

Callers 4

addErrorMethod · 0.95
addFailureMethod · 0.95
addSubTestMethod · 0.95
addExpectedFailureMethod · 0.95

Calls 2

_confirm_picklableMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected