When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
May 14, 2021…6103) When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed. (cherry picked from commit c10c2ec ) Co-authored-by: Antoine Pitrou <antoine@python.org>
pitrou added a commit to pitrou/cpython that referenced this pull request
May 15, 2021…onGH-26103) When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed.. (cherry picked from commit c10c2ec ) Co-authored-by: Antoine Pitrou <antoine@python.org>
miss-islington added a commit that referenced this pull request
May 15, 2021…26103) (GH-26138) When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed. (cherry picked from commit c10c2ec ) Co-authored-by: Antoine Pitrou <antoine@python.org>
pitrou deleted the bpo-37788-thread-join-leak branch
May 15, 2021 09:25miss-islington pushed a commit that referenced this pull request
May 15, 2021…6103) (GH-26142) When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed.. (cherry picked from commit c10c2ec ) Co-authored-by: Antoine Pitrou <antoine@python.org> Automerge-Triggered-By: GH:pitrou
Closed
Closed
Closed
jpmckinney added a commit to open-contracting/kingfisher-process that referenced this pull request
Jan 27, 2022jpmckinney added a commit to open-contracting/yapw that referenced this pull request
Jan 28, 2022Note that the previous code was not thread-safe. A thread-safe version would have been:
for t in list(threads):
if not t.is_alive():
# A set is used for `threads`, because `set.discard()` is O(1) but `list.remove()` is O(n).
threads.discard(t)
# Python 3.8 and below has a memory leak. python/cpython#26103
t.join()
jpmckinney added a commit to open-contracting/kingfisher-process that referenced this pull request
Jan 28, 2022