t/unit/__init__.py
raw| 1 | import atexit |
| 2 | |
| 3 | |
| 4 | def teardown(): |
| 5 | # Workaround for multiprocessing bug where logging |
| 6 | # is attempted after global already collected at shutdown. |
| 7 | cancelled = set() |
| 8 | try: |
| 9 | import multiprocessing.util |
| 10 | cancelled.add(multiprocessing.util._exit_function) |
| 11 | except (AttributeError, ImportError): |
| 12 | pass |
| 13 | |
| 14 | try: |
| 15 | atexit._exithandlers[:] = [ |
| 16 | e for e in atexit._exithandlers if e[0] not in cancelled |
| 17 | ] |
| 18 | except AttributeError: |
| 19 | pass |