(self)
| 1049 | self._delete() |
| 1050 | |
| 1051 | def _stop(self): |
| 1052 | # After calling ._stop(), .is_alive() returns False and .join() returns |
| 1053 | # immediately. ._tstate_lock must be released before calling ._stop(). |
| 1054 | # |
| 1055 | # Normal case: C code at the end of the thread's life |
| 1056 | # (release_sentinel in _threadmodule.c) releases ._tstate_lock, and |
| 1057 | # that's detected by our ._wait_for_tstate_lock(), called by .join() |
| 1058 | # and .is_alive(). Any number of threads _may_ call ._stop() |
| 1059 | # simultaneously (for example, if multiple threads are blocked in |
| 1060 | # .join() calls), and they're not serialized. That's harmless - |
| 1061 | # they'll just make redundant rebindings of ._is_stopped and |
| 1062 | # ._tstate_lock. Obscure: we rebind ._tstate_lock last so that the |
| 1063 | # "assert self._is_stopped" in ._wait_for_tstate_lock() always works |
| 1064 | # (the assert is executed only if ._tstate_lock is None). |
| 1065 | # |
| 1066 | # Special case: _main_thread releases ._tstate_lock via this |
| 1067 | # module's _shutdown() function. |
| 1068 | lock = self._tstate_lock |
| 1069 | if lock is not None: |
| 1070 | assert not lock.locked() |
| 1071 | self._is_stopped = True |
| 1072 | self._tstate_lock = None |
| 1073 | if not self.daemon: |
| 1074 | with _shutdown_locks_lock: |
| 1075 | # Remove our lock and other released locks from _shutdown_locks |
| 1076 | _maintain_shutdown_locks() |
| 1077 | |
| 1078 | def _delete(self): |
| 1079 | "Remove current thread from the dict of currently running threads." |
no test coverage detected