Skip to content

Sphinx build hangs when a BaseException occurs #25161

@saraedum

Description

@saraedum

Python's multiprocessing.Pool hangs when a BaseException that is not an Excepion happens in the function it runs; we need to wrap these in "normal" Exception's so they get thrown correctly by the pool's get.

Here's a minimal Python session to showcase this problem:

Python 2.7.14 (default, Jan  5 2018, 10:41:29) 
[GCC 7.2.1 20171224] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def work(x):
...     raise BaseException(x)
... 
>>> from multiprocessing import Pool
>>> pool = Pool(2)
>>> pool.map_async(work, ["error", "error"]).get()
Process PoolWorker-1:
Process PoolWorker-2:
Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
  File "/usr/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 113, in worker
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 113, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 65, in mapstar
    result = (True, func(*args, **kwds))
    return map(*args)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 65, in mapstar
  File "<stdin>", line 2, in work
    return map(*args)
  File "<stdin>", line 2, in work
BaseException: error
BaseException: error
[hangs]

This upstreams part of Debian's u2-better-sphinx-failure-modes.patch.

CC: @infinity0

Component: doctest framework

Author: Julian Rüth

Branch/Commit: 319849a

Reviewer: Erik Bray

Issue created by migration from https://trac.sagemath.org/ticket/25161

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions