Helper class to remove a dummy thread from threading._active on __del__.
| 1400 | |
| 1401 | |
| 1402 | class _DeleteDummyThreadOnDel: |
| 1403 | ''' |
| 1404 | Helper class to remove a dummy thread from threading._active on __del__. |
| 1405 | ''' |
| 1406 | |
| 1407 | def __init__(self, dummy_thread): |
| 1408 | self._dummy_thread = dummy_thread |
| 1409 | self._tident = dummy_thread.ident |
| 1410 | # Put the thread on a thread local variable so that when |
| 1411 | # the related thread finishes this instance is collected. |
| 1412 | # |
| 1413 | # Note: no other references to this instance may be created. |
| 1414 | # If any client code creates a reference to this instance, |
| 1415 | # the related _DummyThread will be kept forever! |
| 1416 | _thread_local_info._track_dummy_thread_ref = self |
| 1417 | |
| 1418 | def __del__(self, _active_limbo_lock=_active_limbo_lock, _active=_active): |
| 1419 | with _active_limbo_lock: |
| 1420 | if _active.get(self._tident) is self._dummy_thread: |
| 1421 | _active.pop(self._tident, None) |
| 1422 | |
| 1423 | |
| 1424 | # Dummy thread class to represent threads not started here. |
no outgoing calls
no test coverage detected
searching dependent graphs…